1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

seq: update to clap 4

This commit is contained in:
Terts Diepraam 2022-09-30 16:31:12 +02:00
parent d92f2f6195
commit 4cfc90c077
3 changed files with 13 additions and 20 deletions

View file

@ -17,7 +17,7 @@ path = "src/seq.rs"
[dependencies] [dependencies]
bigdecimal = "0.3" bigdecimal = "0.3"
clap = { version = "3.2", features = ["wrap_help", "cargo"] } clap = { version = "4.0", features = ["wrap_help", "cargo"] }
num-bigint = "0.4.0" num-bigint = "0.4.0"
num-traits = "0.2.15" num-traits = "0.2.15"
uucore = { version=">=0.0.16", package="uucore", path="../../uucore", features=["memo"] } uucore = { version=">=0.0.16", package="uucore", path="../../uucore", features=["memo"] }

View file

@ -7,7 +7,7 @@
use std::io::{stdout, ErrorKind, Write}; use std::io::{stdout, ErrorKind, Write};
use std::process::exit; use std::process::exit;
use clap::{crate_version, Arg, Command}; use clap::{crate_version, Arg, ArgAction, Command};
use num_traits::Zero; use num_traits::Zero;
use uucore::error::FromIo; use uucore::error::FromIo;
@ -77,7 +77,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
.map(|s| s.as_str()) .map(|s| s.as_str())
.unwrap_or("\n") .unwrap_or("\n")
.to_string(), .to_string(),
widths: matches.contains_id(OPT_WIDTHS), widths: matches.get_flag(OPT_WIDTHS),
format: matches.get_one::<String>(OPT_FORMAT).map(|s| s.as_str()), format: matches.get_one::<String>(OPT_FORMAT).map(|s| s.as_str()),
}; };
@ -152,7 +152,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} }
} }
pub fn uu_app<'a>() -> Command<'a> { pub fn uu_app() -> Command {
Command::new(uucore::util_name()) Command::new(uucore::util_name())
.trailing_var_arg(true) .trailing_var_arg(true)
.allow_negative_numbers(true) .allow_negative_numbers(true)
@ -164,38 +164,31 @@ pub fn uu_app<'a>() -> Command<'a> {
Arg::new(OPT_SEPARATOR) Arg::new(OPT_SEPARATOR)
.short('s') .short('s')
.long("separator") .long("separator")
.help("Separator character (defaults to \\n)") .help("Separator character (defaults to \\n)"),
.takes_value(true)
.number_of_values(1),
) )
.arg( .arg(
Arg::new(OPT_TERMINATOR) Arg::new(OPT_TERMINATOR)
.short('t') .short('t')
.long("terminator") .long("terminator")
.help("Terminator character (defaults to \\n)") .help("Terminator character (defaults to \\n)"),
.takes_value(true)
.number_of_values(1),
) )
.arg( .arg(
Arg::new(OPT_WIDTHS) Arg::new(OPT_WIDTHS)
.short('w') .short('w')
.long("widths") .long("widths")
.help("Equalize widths of all numbers by padding with zeros"), .help("Equalize widths of all numbers by padding with zeros")
.action(ArgAction::SetTrue),
) )
.arg( .arg(
Arg::new(OPT_FORMAT) Arg::new(OPT_FORMAT)
.short('f') .short('f')
.long(OPT_FORMAT) .long(OPT_FORMAT)
.help("use printf style floating-point FORMAT") .help("use printf style floating-point FORMAT"),
.takes_value(true)
.number_of_values(1),
) )
.arg( .arg(
Arg::new(ARG_NUMBERS) Arg::new(ARG_NUMBERS)
.multiple_occurrences(true) .action(ArgAction::Append)
.takes_value(true) .num_args(1..=3),
.max_values(3)
.required(true),
) )
} }

View file

@ -26,13 +26,13 @@ fn test_hex_rejects_sign_after_identifier() {
.fails() .fails()
.no_stdout() .no_stdout()
.stderr_contains("which wasn't expected, or isn't valid in this context") .stderr_contains("which wasn't expected, or isn't valid in this context")
.stderr_contains("For more information try --help"); .stderr_contains("For more information try '--help'");
new_ucmd!() new_ucmd!()
.args(&["-0x+123ABC"]) .args(&["-0x+123ABC"])
.fails() .fails()
.no_stdout() .no_stdout()
.stderr_contains("which wasn't expected, or isn't valid in this context") .stderr_contains("which wasn't expected, or isn't valid in this context")
.stderr_contains("For more information try --help"); .stderr_contains("For more information try '--help'");
} }
#[test] #[test]