diff --git a/du/du.rs b/du/du.rs index c0a9d46b8..eaf3a952b 100644 --- a/du/du.rs +++ b/du/du.rs @@ -155,24 +155,28 @@ fn main() { }; if matches.opt_present("help") { - println!("du {} - estimate file space usage", VERSION); - println!(""); - println!("Usage:"); - println!(" {0:s} [OPTION]... [FILE]...", program); - println!(" {0:s} [OPTION]... --files0-from=F", program); - println!(""); - println!("{}", getopts::usage("Summarize disk usage of each FILE, recursively for directories.", opts)); - println!("Display values are in units of the first available SIZE from + println!("{program} {version} - estimate file space usage + +Usage + {program} [OPTION]... [FILE]... + {program} [OPTION]... --files0-from=F + +{usage} + +Display values are in units of the first available SIZE from --block-size, and the DU_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environ‐ ment variables. Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set). SIZE is an integer and optional unit (example: 10M is 10*1024*1024). Units are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB, ... (pow‐ -ers of 1000)."); +ers of 1000).", + program = program, + version = VERSION, + usage = getopts::usage("Summarize disk usage of each FILE, recursively for directories.", opts)); return } else if matches.opt_present("version") { - println!("du version: {}", VERSION); + println!("{} version: {}", program, VERSION); return } @@ -205,11 +209,11 @@ ers of 1000)."); let MB = match matches.opt_present("si") { true => 1000 * 1000, - false => 1024 * 1024, + false => 1024 * 1024, }; let KB = match matches.opt_present("si") { true => 1000, - false => 1024, + false => 1024, }; let block_size = match matches.opt_str("block-size") { @@ -220,7 +224,7 @@ ers of 1000)."); let mut letters = ~[]; for c in s.chars() { if found_letter && c.is_digit() || !found_number && !c.is_digit() { - println!("du: invalid --block-size argument '{}'", s); + println!("{}: invalid --block-size argument '{}'", program, s); return } else if c.is_digit() { found_number = true; @@ -243,7 +247,7 @@ ers of 1000)."); "ZB" => 1000 * 1000 * 1000 * 1000 * 1000 * 1000 * 1000, "YB" => 1000 * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 * 1000, _ => { - println!("du: invalid --block-size argument '{}'", s); return + println!("{}: invalid --block-size argument '{}'", program, s); return } }; number * multiple @@ -276,13 +280,12 @@ ers of 1000)."); "long-iso" => "%Y-%m-%d %H:%M", "iso" => "%Y-%m-%d", _ => { - println!(" -du: invalid argument 'awdwa' for 'time style' + println!("{program}: invalid argument '{}' for 'time style' Valid arguments are: - 'full-iso' - 'long-iso' - 'iso' -Try 'du --help' for more information."); +Try '{program} --help' for more information.", s, program = program); return } } @@ -318,10 +321,10 @@ Try 'du --help' for more information."); "created" => stat.created, "modified" => stat.modified, _ => { - println!("du: invalid argument 'modified' for '--time' + println!("{program}: invalid argument 'modified' for '--time' Valid arguments are: - 'accessed', 'created', 'modified' - Try 'du --help' for more information."); + Try '{program} --help' for more information.", program = program); return } },