Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

seq: rename "--widths" to "--equal-width" #5012

Merged
merged 1 commit into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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