1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

du: use multi-line strings and print the actual name, not a literal du.

This commit is contained in:
Huon Wilson 2014-03-19 17:57:35 +11:00
parent 4d9c71e541
commit a4c40503be

View file

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