Merge pull request #621 from jbcrail/standardize-name-version

Standardize display of utility name and version.
This commit is contained in:
Heather
2015-05-25 22:10:08 +03:00
26 changed files with 56 additions and 55 deletions
+2 -2
View File
@@ -48,7 +48,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
Err(f) => { crash!(1, "{}", f) }
};
if matches.opt_present("help") {
let msg = format!("{name} v{version}
let msg = format!("{name} {version}
Usage:
{program} [OPTION]... MODE[,MODE]... FILE...
@@ -63,7 +63,7 @@ Each MODE is of the form '[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=]?[0-7]+'.",
print!("{}", opts.usage(&msg));
return 0;
} else if matches.opt_present("version") {
println!("{} v{}", NAME, VERSION);
println!("{} {}", NAME, VERSION);
} else if matches.free.is_empty() && matches.opt_present("reference") || matches.free.len() < 2 {
show_error!("missing an argument");
show_error!("for help, try '{} --help'", NAME);
+2 -2
View File
@@ -202,11 +202,11 @@ fn set_user(user: &str) {
}
fn version() {
println!("{} v{}", NAME, VERSION)
println!("{} {}", NAME, VERSION)
}
fn help_menu(options: Options) {
let msg = format!("{0} v{1}
let msg = format!("{0} {1}
Usage:
{0} [OPTION]... NEWROOT [COMMAND [ARG]...]
+1 -1
View File
@@ -210,7 +210,7 @@ ers of 1000).",
usage = opts.usage("Summarize disk usage of each FILE, recursively for directories."));
return 0;
} else if matches.opt_present("version") {
println!("{} version: {}", NAME, VERSION);
println!("{} {}", NAME, VERSION);
return 0;
}
+14 -13
View File
@@ -21,6 +21,9 @@ use std::process::Command;
#[macro_use]
mod util;
static NAME: &'static str = "env";
static VERSION: &'static str = "1.0.0";
struct options {
ignore_env: bool,
null: bool,
@@ -29,8 +32,8 @@ struct options {
program: Vec<String>
}
fn usage(prog: &str) {
println!("Usage: {} [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]", prog);
fn usage() {
println!("Usage: {} [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]", NAME);
println!("Set each NAME to VALUE in the environment and run COMMAND\n");
println!("Possible options are:");
println!(" -i --ignore-environment\t start with an empty environment");
@@ -42,7 +45,7 @@ fn usage(prog: &str) {
}
fn version() {
println!("env 1.0.0");
println!("{} {}", NAME, VERSION);
}
// print name=value env pairs on screen
@@ -54,8 +57,6 @@ fn print_env(null: bool) {
}
pub fn uumain(args: Vec<String>) -> i32 {
let prog = &args[0];
// to handle arguments the same way than GNU env, we can't use getopts
let mut opts = Box::new(options {
ignore_env: false,
@@ -94,7 +95,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
}
} else if opt.starts_with("--") {
match opt.as_ref() {
"--help" => { usage(prog); return 0; }
"--help" => { usage(); return 0; }
"--version" => { version(); return 0; }
"--ignore-environment" => opts.ignore_env = true,
@@ -103,14 +104,14 @@ pub fn uumain(args: Vec<String>) -> i32 {
let var = iter.next();
match var {
None => println!("{}: this option requires an argument: {}", prog, opt),
None => println!("{}: this option requires an argument: {}", NAME, opt),
Some(s) => opts.unsets.push(s.to_string())
}
}
_ => {
println!("{}: invalid option \"{}\"", prog, *opt);
println!("Type \"{} --help\" for detailed informations", prog);
println!("{}: invalid option \"{}\"", NAME, *opt);
println!("Type \"{} --help\" for detailed informations", NAME);
return 1;
}
}
@@ -128,7 +129,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
for c in chars {
// short versions of options
match c {
'h' => { usage(prog); return 0; }
'h' => { usage(); return 0; }
'V' => { version(); return 0; }
'i' => opts.ignore_env = true,
'0' => opts.null = true,
@@ -136,13 +137,13 @@ pub fn uumain(args: Vec<String>) -> i32 {
let var = iter.next();
match var {
None => println!("{}: this option requires an argument: {}", prog, opt),
None => println!("{}: this option requires an argument: {}", NAME, opt),
Some(s) => opts.unsets.push(s.to_string())
}
}
_ => {
println!("{}: illegal option -- {}", prog, c);
println!("Type \"{} --help\" for detailed informations", prog);
println!("{}: illegal option -- {}", NAME, c);
println!("Type \"{} --help\" for detailed informations", NAME);
return 1;
}
}
+1 -1
View File
@@ -117,7 +117,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
}
if matches.opt_present("V") {
println!("{} v{}", NAME, VERSION);
println!("{} {}", NAME, VERSION);
return 0;
}
+1 -1
View File
@@ -94,7 +94,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
}
if matches.opt_present("V") || matches.opt_present("h") {
println!("uutils {} v{}", NAME, VERSION);
println!("{} {}", NAME, VERSION);
return 0
}
+2 -2
View File
@@ -40,14 +40,14 @@ pub fn uumain(args: Vec<String>) -> i32 {
};
if matches.opt_present("h") {
println!("{} v{}", NAME, VERSION);
println!("{} {}", NAME, VERSION);
println!("");
println!("Usage:");
println!(" {} [OPTION]... [FILE]...", NAME);
println!("");
print!("{}", opts.usage("Writes each file (or standard input if no files are given) to standard output whilst breaking long lines"));
} else if matches.opt_present("V") {
println!("{} v{}", NAME, VERSION);
println!("{} {}", NAME, VERSION);
} else {
let bytes = matches.opt_present("b");
let spaces = matches.opt_present("s");
+2 -2
View File
@@ -34,9 +34,9 @@ pub fn uumain(args: Vec<String>) -> i32 {
};
if matches.opt_present("version") {
println!("{} v{}", NAME, VERSION);
println!("{} {}", NAME, VERSION);
} else if matches.opt_present("help") {
let msg = format!("{0} v{1}
let msg = format!("{0} {1}
Usage:
{0} [OPTION]... [USER]...
+2 -2
View File
@@ -138,7 +138,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
}
fn version() {
pipe_println!("{} v{}", NAME, VERSION);
pipe_println!("{} {}", NAME, VERSION);
}
fn usage(program: &str, binary_name: &str, opts: &getopts::Options) {
@@ -148,7 +148,7 @@ fn usage(program: &str, binary_name: &str, opts: &getopts::Options) {
format!(" {} {{--md5|--sha1|--sha224|--sha256|--sha384|--sha512}} [OPTION]... [FILE]...", program)
};
let msg = format!("{} v{}
let msg = format!("{} {}
Usage:
{}
+1 -1
View File
@@ -179,5 +179,5 @@ fn head<T: Read>(reader: &mut BufReader<T>, count: usize, use_bytes: bool) -> bo
}
fn version() {
println!("{} version {}", NAME, VERSION);
println!("{} {}", NAME, VERSION);
}
+2 -2
View File
@@ -50,7 +50,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
return 0;
}
if matches.opt_present("version") {
println!("{} v{}", NAME, VERSION);
println!("{} {}", NAME, VERSION);
return 0;
}
let verbose = matches.opt_present("verbose");
@@ -79,7 +79,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
}
fn print_help(opts: &getopts::Options) {
println!("{} v{} - make a new directory with the given path", NAME, VERSION);
println!("{} {}", NAME, VERSION);
println!("");
println!("Usage:");
print!("{}", opts.usage("Create the given DIRECTORY(ies) if they do not exist"));
+5 -5
View File
@@ -106,7 +106,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
"none" | "off" => BackupMode::NoBackup,
x => {
show_error!("invalid argument {} for backup type\n\
Try 'mv --help' for more information.", x);
Try '{} --help' for more information.", x, NAME);
return 1;
}
}
@@ -117,7 +117,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
if overwrite_mode == OverwriteMode::NoClobber && backup_mode != BackupMode::NoBackup {
show_error!("options --backup and --no-clobber are mutually exclusive\n\
Try 'mv --help' for more information.");
Try '{} --help' for more information.", NAME);
return 1;
}
@@ -126,7 +126,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
Some(x) => x,
None => {
show_error!("option '--suffix' requires an argument\n\
Try 'mv --help' for more information.");
Try '{} --help' for more information.", NAME);
return 1;
}
}
@@ -180,7 +180,7 @@ fn exec(files: &[PathBuf], b: Behaviour) -> i32 {
match files {
[] | [_] => {
show_error!("missing file operand\n\
Try 'mv --help' for more information.");
Try '{} --help' for more information.", NAME);
return 1;
},
[ref source, ref target] => {
@@ -220,7 +220,7 @@ fn exec(files: &[PathBuf], b: Behaviour) -> i32 {
fs => {
if b.no_target_dir {
show_error!("mv: extra operand {}\n\
Try 'mv --help' for more information.", fs[2].display());
Try '{} --help' for more information.", fs[2].display(), NAME);
return 1;
}
let target_dir = fs.last().unwrap();
+2 -2
View File
@@ -47,12 +47,12 @@ pub fn uumain(args: Vec<String>) -> i32 {
};
if matches.opt_present("version") {
println!("{} v{}", NAME, VERSION);
println!("{} {}", NAME, VERSION);
return 0;
}
if matches.opt_present("help") {
let msg = format!("{0} v{1}
let msg = format!("{0} {1}
Usage:
{0} [OPTIONS] [COMMAND [ARGS]]
+1 -1
View File
@@ -324,5 +324,5 @@ fn print_usage(opts: &getopts::Options) {
}
fn version() {
println!("{} version {}", NAME, VERSION);
println!("{} {}", NAME, VERSION);
}
+2 -2
View File
@@ -53,7 +53,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
}
};
if matches.opt_present("V") { println!("{} v{}", NAME, VERSION); return 0 }
if matches.opt_present("V") { println!("{} {}", NAME, VERSION); return 0 }
if matches.opt_present("h") { show_usage(&opts); return 0 }
if matches.free.len() == 0 {
@@ -133,7 +133,7 @@ fn find_stdout() -> File {
}
fn show_usage(opts: &getopts::Options) {
let msg = format!("{0} v{1}
let msg = format!("{0} {1}
Usage:
{0} COMMAND [ARG]...
+1 -1
View File
@@ -44,7 +44,7 @@ Usage:
Print the full filename of the current working directory.", NAME, VERSION);
print!("{}", opts.usage(&msg));
} else if matches.opt_present("version") {
println!("{} version: {}", NAME, VERSION);
println!("{} {}", NAME, VERSION);
} else {
println!("{}", env::current_dir().unwrap().display());
}
+1 -1
View File
@@ -156,7 +156,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
}
if matches.opt_present("version") {
println!("{} v{}", NAME, VERSION);
println!("{} {}", NAME, VERSION);
return 0;
}
+1 -1
View File
@@ -116,7 +116,7 @@ fn resolve_path(path: &str, strip: bool, zero: bool, quiet: bool) -> bool {
}
fn version() {
println!("{} v{}", NAME, VERSION)
println!("{} {}", NAME, VERSION)
}
fn show_usage(opts: &getopts::Options) {
+1 -1
View File
@@ -84,7 +84,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
}
fn version() {
println!("{} v{}", NAME, VERSION)
println!("{} {}", NAME, VERSION)
}
fn show_usage(opts: &getopts::Options) {
+2 -2
View File
@@ -50,7 +50,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
}
};
if matches.opt_present("help") {
let msg = format!("{0} v{1}
let msg = format!("{0} {1}
Usage:
{0} [OPTION]... [FILE]
@@ -61,7 +61,7 @@ Write a random permutation of the input lines to standard output.
With no FILE, or when FILE is -, read standard input.", NAME, VERSION);
print!("{}", opts.usage(&msg));
} else if matches.opt_present("version") {
println!("{} v{}", NAME, VERSION);
println!("{} {}", NAME, VERSION);
} else {
let echo = matches.opt_present("echo");
let mode = match matches.opt_str("input-range") {

Some files were not shown because too many files have changed in this diff Show More