From c05dbfa3b4f813019c2c668ace7fbc2fbf806c93 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 26 Jun 2023 16:21:59 +0200 Subject: [PATCH] seq: rename "--widths" to "--equal-width" for compatibility with GNU seq --- src/uu/seq/src/seq.rs | 14 +++++++------- tests/by-util/test_seq.rs | 11 +++++++---- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/uu/seq/src/seq.rs b/src/uu/seq/src/seq.rs index 97382ed1b05..4562ddb7d01 100644 --- a/src/uu/seq/src/seq.rs +++ b/src/uu/seq/src/seq.rs @@ -31,7 +31,7 @@ const USAGE: &str = help_usage!("seq.md"); const OPT_SEPARATOR: &str = "separator"; const OPT_TERMINATOR: &str = "terminator"; -const OPT_WIDTHS: &str = "widths"; +const OPT_EQUAL_WIDTH: &str = "equal-width"; const OPT_FORMAT: &str = "format"; const ARG_NUMBERS: &str = "numbers"; @@ -40,7 +40,7 @@ const ARG_NUMBERS: &str = "numbers"; struct SeqOptions<'a> { separator: String, terminator: String, - widths: bool, + equal_width: bool, format: Option<&'a str>, } @@ -74,7 +74,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { .map(|s| s.as_str()) .unwrap_or("\n") .to_string(), - widths: matches.get_flag(OPT_WIDTHS), + equal_width: matches.get_flag(OPT_EQUAL_WIDTH), format: matches.get_one::(OPT_FORMAT).map(|s| s.as_str()), }; @@ -123,7 +123,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { (first, increment, last), &options.separator, &options.terminator, - options.widths, + options.equal_width, padding, options.format, ) @@ -137,7 +137,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { largest_dec, &options.separator, &options.terminator, - options.widths, + options.equal_width, padding, options.format, ), @@ -170,9 +170,9 @@ pub fn uu_app() -> Command { .help("Terminator character (defaults to \\n)"), ) .arg( - Arg::new(OPT_WIDTHS) + Arg::new(OPT_EQUAL_WIDTH) .short('w') - .long("widths") + .long("equal-width") .help("Equalize widths of all numbers by padding with zeros") .action(ArgAction::SetTrue), ) diff --git a/tests/by-util/test_seq.rs b/tests/by-util/test_seq.rs index 63015b24a21..02509b3b5c6 100644 --- a/tests/by-util/test_seq.rs +++ b/tests/by-util/test_seq.rs @@ -208,10 +208,13 @@ fn test_separator_and_terminator() { #[test] fn test_equalize_widths() { - new_ucmd!() - .args(&["-w", "5", "10"]) - .run() - .stdout_is("05\n06\n07\n08\n09\n10\n"); + let args = ["-w", "--equal-width"]; + for arg in args { + new_ucmd!() + .args(&[arg, "5", "10"]) + .run() + .stdout_is("05\n06\n07\n08\n09\n10\n"); + } } #[test]