Skip to content

Commit

Permalink
Merge pull request #5012 from cakebaker/seq_rename_widths_to_equal_width
Browse files Browse the repository at this point in the history
seq: rename "--widths" to "--equal-width"
  • Loading branch information
sylvestre authored Jun 28, 2023
2 parents 5ce7ae5 + c05dbfa commit 682e0e3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
14 changes: 7 additions & 7 deletions src/uu/seq/src/seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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>,
}

Expand Down Expand Up @@ -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::<String>(OPT_FORMAT).map(|s| s.as_str()),
};

Expand Down Expand Up @@ -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,
)
Expand All @@ -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,
),
Expand Down Expand Up @@ -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),
)
Expand Down
11 changes: 7 additions & 4 deletions tests/by-util/test_seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 682e0e3

Please sign in to comment.