mirror of
https://github.com/uutils/coreutils
synced 2024-12-13 23:02:38 +00:00
Simplify opt checks
This commit is contained in:
parent
a4899a1b31
commit
61a232eb0a
4 changed files with 15 additions and 15 deletions
16
cat/cat.rs
16
cat/cat.rs
|
@ -42,7 +42,7 @@ fn main() {
|
|||
return
|
||||
}
|
||||
};
|
||||
if matches.opts_present([~"h", ~"help"]) {
|
||||
if matches.opt_present("help") {
|
||||
println("cat 1.0.0");
|
||||
println("");
|
||||
println("Usage:");
|
||||
|
@ -53,22 +53,22 @@ fn main() {
|
|||
println("With no FILE, or when FILE is -, read standard input.");
|
||||
return;
|
||||
}
|
||||
if matches.opts_present([~"V", ~"version"]) {
|
||||
if matches.opt_present("version") {
|
||||
println("cat 1.0.0");
|
||||
return;
|
||||
}
|
||||
|
||||
let mut number_mode = NumberNone;
|
||||
if matches.opts_present([~"n", ~"number"]) {
|
||||
if matches.opt_present("number") {
|
||||
number_mode = NumberAll;
|
||||
}
|
||||
if matches.opts_present([~"b", ~"number-nonblank"]) {
|
||||
if matches.opt_present("number-nonblank") {
|
||||
number_mode = NumberNonEmpty;
|
||||
}
|
||||
let show_nonprint = matches.opts_present([~"v", ~"show-nonprinting", ~"A", ~"show-all", ~"t", ~"e"]);
|
||||
let show_ends = matches.opts_present([~"E", ~"show-ends", ~"A", ~"show-all", ~"e"]);
|
||||
let show_tabs = matches.opts_present([~"T", ~"show-tabs", ~"A", ~"show-all", ~"t"]);
|
||||
let squeeze_blank = matches.opts_present([~"s", ~"squeeze-blank"]);
|
||||
let show_nonprint = matches.opts_present([~"show-nonprinting", ~"show-all", ~"t", ~"e"]);
|
||||
let show_ends = matches.opts_present([~"show-ends", ~"show-all", ~"e"]);
|
||||
let show_tabs = matches.opts_present([~"show-tabs", ~"show-all", ~"t"]);
|
||||
let squeeze_blank = matches.opt_present("squeeze-blank");
|
||||
let mut files = matches.free;
|
||||
if files.is_empty() {
|
||||
files = ~[~"-"];
|
||||
|
|
|
@ -34,7 +34,7 @@ fn main() {
|
|||
return
|
||||
}
|
||||
};
|
||||
if matches.opts_present([~"h", ~"help"]) {
|
||||
if matches.opt_present("help") {
|
||||
println("printenv 1.0.0");
|
||||
println("");
|
||||
println("Usage:");
|
||||
|
@ -43,12 +43,12 @@ fn main() {
|
|||
print(groups::usage("Prints the given environment VARIABLE(s), otherwise prints them all.", opts));
|
||||
return;
|
||||
}
|
||||
if matches.opts_present([~"V", ~"version"]) {
|
||||
if matches.opt_present("version") {
|
||||
println("printenv 1.0.0");
|
||||
return;
|
||||
}
|
||||
let mut separator = "\n";
|
||||
if matches.opts_present([~"0", ~"null"]) {
|
||||
if matches.opt_present("null") {
|
||||
separator = "\x00";
|
||||
};
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ fn main() {
|
|||
Ok(m) => m,
|
||||
Err(f) => fail2!(f.to_err_msg()),
|
||||
};
|
||||
if matches.opt_present("h") || matches.opt_present("help") {
|
||||
if matches.opt_present("help") {
|
||||
println("whoami 1.0.0");
|
||||
println("");
|
||||
println("Usage:");
|
||||
|
@ -59,7 +59,7 @@ fn main() {
|
|||
print(groups::usage("print effective userid", opts));
|
||||
return;
|
||||
}
|
||||
if matches.opt_present("V") || matches.opt_present("version") {
|
||||
if matches.opt_present("version") {
|
||||
println("whoami 1.0.0");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ fn main() {
|
|||
return
|
||||
}
|
||||
};
|
||||
if matches.opts_present([~"h", ~"help"]) {
|
||||
if matches.opt_present("help") {
|
||||
println("yes 1.0.0");
|
||||
println("");
|
||||
println("Usage:");
|
||||
|
@ -42,7 +42,7 @@ fn main() {
|
|||
print(groups::usage("Repeatedly output a line with all specified STRING(s), or 'y'.", opts));
|
||||
return;
|
||||
}
|
||||
if matches.opts_present([~"V", ~"version"]) {
|
||||
if matches.opt_present("version") {
|
||||
println("yes 1.0.0");
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue