mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
seq: rename "--widths" to "--equal-width"
for compatibility with GNU seq
This commit is contained in:
parent
9149409065
commit
c05dbfa3b4
2 changed files with 14 additions and 11 deletions
|
@ -31,7 +31,7 @@ const USAGE: &str = help_usage!("seq.md");
|
||||||
|
|
||||||
const OPT_SEPARATOR: &str = "separator";
|
const OPT_SEPARATOR: &str = "separator";
|
||||||
const OPT_TERMINATOR: &str = "terminator";
|
const OPT_TERMINATOR: &str = "terminator";
|
||||||
const OPT_WIDTHS: &str = "widths";
|
const OPT_EQUAL_WIDTH: &str = "equal-width";
|
||||||
const OPT_FORMAT: &str = "format";
|
const OPT_FORMAT: &str = "format";
|
||||||
|
|
||||||
const ARG_NUMBERS: &str = "numbers";
|
const ARG_NUMBERS: &str = "numbers";
|
||||||
|
@ -40,7 +40,7 @@ const ARG_NUMBERS: &str = "numbers";
|
||||||
struct SeqOptions<'a> {
|
struct SeqOptions<'a> {
|
||||||
separator: String,
|
separator: String,
|
||||||
terminator: String,
|
terminator: String,
|
||||||
widths: bool,
|
equal_width: bool,
|
||||||
format: Option<&'a str>,
|
format: Option<&'a str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,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.get_flag(OPT_WIDTHS),
|
equal_width: matches.get_flag(OPT_EQUAL_WIDTH),
|
||||||
format: matches.get_one::<String>(OPT_FORMAT).map(|s| s.as_str()),
|
format: matches.get_one::<String>(OPT_FORMAT).map(|s| s.as_str()),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
(first, increment, last),
|
(first, increment, last),
|
||||||
&options.separator,
|
&options.separator,
|
||||||
&options.terminator,
|
&options.terminator,
|
||||||
options.widths,
|
options.equal_width,
|
||||||
padding,
|
padding,
|
||||||
options.format,
|
options.format,
|
||||||
)
|
)
|
||||||
|
@ -137,7 +137,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
largest_dec,
|
largest_dec,
|
||||||
&options.separator,
|
&options.separator,
|
||||||
&options.terminator,
|
&options.terminator,
|
||||||
options.widths,
|
options.equal_width,
|
||||||
padding,
|
padding,
|
||||||
options.format,
|
options.format,
|
||||||
),
|
),
|
||||||
|
@ -170,9 +170,9 @@ pub fn uu_app() -> Command {
|
||||||
.help("Terminator character (defaults to \\n)"),
|
.help("Terminator character (defaults to \\n)"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(OPT_WIDTHS)
|
Arg::new(OPT_EQUAL_WIDTH)
|
||||||
.short('w')
|
.short('w')
|
||||||
.long("widths")
|
.long("equal-width")
|
||||||
.help("Equalize widths of all numbers by padding with zeros")
|
.help("Equalize widths of all numbers by padding with zeros")
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
|
|
|
@ -208,10 +208,13 @@ fn test_separator_and_terminator() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_equalize_widths() {
|
fn test_equalize_widths() {
|
||||||
|
let args = ["-w", "--equal-width"];
|
||||||
|
for arg in args {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-w", "5", "10"])
|
.args(&[arg, "5", "10"])
|
||||||
.run()
|
.run()
|
||||||
.stdout_is("05\n06\n07\n08\n09\n10\n");
|
.stdout_is("05\n06\n07\n08\n09\n10\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue