--- a/rust/rhg/src/commands/debugrhgsparse.rs Mon Nov 14 17:18:56 2022 +0100
+++ b/rust/rhg/src/commands/debugrhgsparse.rs Tue Nov 15 00:02:43 2022 +0100
@@ -1,19 +1,21 @@
-use std::os::unix::prelude::OsStrExt;
+use std::{
+ ffi::{OsStr, OsString},
+ os::unix::prelude::OsStrExt,
+};
use crate::error::CommandError;
-use clap::SubCommand;
use hg::{self, utils::hg_path::HgPath};
pub const HELP_TEXT: &str = "";
-pub fn args() -> clap::App<'static, 'static> {
- SubCommand::with_name("debugrhgsparse")
+pub fn args() -> clap::Command {
+ clap::command!("debugrhgsparse")
.arg(
- clap::Arg::with_name("files")
+ clap::Arg::new("files")
+ .value_name("FILES")
.required(true)
- .multiple(true)
- .empty_values(false)
- .value_name("FILES")
+ .num_args(1..)
+ .value_parser(clap::value_parser!(std::ffi::OsString))
.help("Files to check against sparse profile"),
)
.about(HELP_TEXT)
@@ -23,8 +25,12 @@
let repo = invocation.repo?;
let (matcher, _warnings) = hg::sparse::matcher(&repo).unwrap();
- let files = invocation.subcommand_args.values_of_os("files");
+ let files = invocation.subcommand_args.get_many::<OsString>("files");
if let Some(files) = files {
+ let files: Vec<&OsStr> = files
+ .filter(|s| !s.is_empty())
+ .map(|s| s.as_os_str())
+ .collect();
for file in files {
invocation.ui.write_stdout(b"matches: ")?;
invocation.ui.write_stdout(