mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
Simplify opt checks
This commit is contained in:
+8
-8
@@ -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";
|
||||
};
|
||||
|
||||
|
||||
+2
-2
@@ -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;
|
||||
}
|
||||
|
||||
+2
-2
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user