From 4da6d58a6be95bf1e741bc7ff7472aa677decae7 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Sun, 18 Feb 2024 13:32:00 +0100 Subject: [PATCH] numfmt: remove clap workaround --- src/uu/numfmt/src/numfmt.rs | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/src/uu/numfmt/src/numfmt.rs b/src/uu/numfmt/src/numfmt.rs index d158072fb..80a2051bd 100644 --- a/src/uu/numfmt/src/numfmt.rs +++ b/src/uu/numfmt/src/numfmt.rs @@ -229,29 +229,9 @@ fn parse_options(args: &ArgMatches) -> Result { }) } -// If the --format argument and its value are provided separately, they are concatenated to avoid a -// potential clap error. For example: "--format --%f--" is changed to "--format=--%f--". -fn concat_format_arg_and_value(args: &[String]) -> Vec { - let mut processed_args: Vec = Vec::with_capacity(args.len()); - let mut iter = args.iter().peekable(); - - while let Some(arg) = iter.next() { - if arg == "--format" && iter.peek().is_some() { - processed_args.push(format!("--format={}", iter.peek().unwrap())); - iter.next(); - } else { - processed_args.push(arg.to_string()); - } - } - - processed_args -} - #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { - let args = args.collect_ignore(); - - let matches = uu_app().try_get_matches_from(concat_format_arg_and_value(&args))?; + let matches = uu_app().try_get_matches_from(args)?; let options = parse_options(&matches).map_err(NumfmtError::IllegalArgument)?; @@ -300,7 +280,8 @@ pub fn uu_app() -> Command { Arg::new(options::FORMAT) .long(options::FORMAT) .help("use printf style floating-point FORMAT; see FORMAT below for details") - .value_name("FORMAT"), + .value_name("FORMAT") + .allow_hyphen_values(true), ) .arg( Arg::new(options::FROM)