1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-09-18 04:36:18 +00:00

du: clap 3

This commit is contained in:
Terts Diepraam 2022-01-11 13:24:40 +01:00
parent db1e630c6c
commit 1f2c3064b8
2 changed files with 46 additions and 46 deletions

View file

@ -15,7 +15,7 @@ edition = "2018"
path = "src/du.rs" path = "src/du.rs"
[dependencies] [dependencies]
clap = { version = "2.33", features = ["wrap_help"] } clap = { version = "3.0", features = ["wrap_help", "cargo"] }
chrono = "0.4" chrono = "0.4"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" } uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" } uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }

View file

@ -462,7 +462,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let usage = usage(); let usage = usage();
let matches = uu_app().usage(&usage[..]).get_matches_from(args); let matches = uu_app().override_usage(&usage[..]).get_matches_from(args);
let summarize = matches.is_present(options::SUMMARIZE); let summarize = matches.is_present(options::SUMMARIZE);
@ -625,19 +625,19 @@ fn parse_depth(max_depth_str: Option<&str>, summarize: bool) -> UResult<Option<u
} }
} }
pub fn uu_app() -> App<'static, 'static> { pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name()) App::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(SUMMARY) .about(SUMMARY)
.after_help(LONG_HELP) .after_help(LONG_HELP)
.arg( .arg(
Arg::with_name(options::ALL) Arg::new(options::ALL)
.short("a") .short('a')
.long(options::ALL) .long(options::ALL)
.help("write counts for all files, not just directories"), .help("write counts for all files, not just directories"),
) )
.arg( .arg(
Arg::with_name(options::APPARENT_SIZE) Arg::new(options::APPARENT_SIZE)
.long(options::APPARENT_SIZE) .long(options::APPARENT_SIZE)
.help( .help(
"print apparent sizes, rather than disk usage \ "print apparent sizes, rather than disk usage \
@ -647,8 +647,8 @@ pub fn uu_app() -> App<'static, 'static> {
.alias("app") // The GNU test suite uses this alias .alias("app") // The GNU test suite uses this alias
) )
.arg( .arg(
Arg::with_name(options::BLOCK_SIZE) Arg::new(options::BLOCK_SIZE)
.short("B") .short('B')
.long(options::BLOCK_SIZE) .long(options::BLOCK_SIZE)
.value_name("SIZE") .value_name("SIZE")
.help( .help(
@ -657,20 +657,20 @@ pub fn uu_app() -> App<'static, 'static> {
) )
) )
.arg( .arg(
Arg::with_name(options::BYTES) Arg::new(options::BYTES)
.short("b") .short('b')
.long("bytes") .long("bytes")
.help("equivalent to '--apparent-size --block-size=1'") .help("equivalent to '--apparent-size --block-size=1'")
) )
.arg( .arg(
Arg::with_name(options::TOTAL) Arg::new(options::TOTAL)
.long("total") .long("total")
.short("c") .short('c')
.help("produce a grand total") .help("produce a grand total")
) )
.arg( .arg(
Arg::with_name(options::MAX_DEPTH) Arg::new(options::MAX_DEPTH)
.short("d") .short('d')
.long("max-depth") .long("max-depth")
.value_name("N") .value_name("N")
.help( .help(
@ -680,78 +680,78 @@ pub fn uu_app() -> App<'static, 'static> {
) )
) )
.arg( .arg(
Arg::with_name(options::HUMAN_READABLE) Arg::new(options::HUMAN_READABLE)
.long("human-readable") .long("human-readable")
.short("h") .short('h')
.help("print sizes in human readable format (e.g., 1K 234M 2G)") .help("print sizes in human readable format (e.g., 1K 234M 2G)")
) )
.arg( .arg(
Arg::with_name(options::INODES) Arg::new(options::INODES)
.long(options::INODES) .long(options::INODES)
.help( .help(
"list inode usage information instead of block usage like --block-size=1K" "list inode usage information instead of block usage like --block-size=1K"
) )
) )
.arg( .arg(
Arg::with_name(options::BLOCK_SIZE_1K) Arg::new(options::BLOCK_SIZE_1K)
.short("k") .short('k')
.help("like --block-size=1K") .help("like --block-size=1K")
) )
.arg( .arg(
Arg::with_name(options::COUNT_LINKS) Arg::new(options::COUNT_LINKS)
.short("l") .short('l')
.long("count-links") .long("count-links")
.help("count sizes many times if hard linked") .help("count sizes many times if hard linked")
) )
.arg( .arg(
Arg::with_name(options::DEREFERENCE) Arg::new(options::DEREFERENCE)
.short("L") .short('L')
.long(options::DEREFERENCE) .long(options::DEREFERENCE)
.help("dereference all symbolic links") .help("dereference all symbolic links")
) )
// .arg( // .arg(
// Arg::with_name("no-dereference") // Arg::new("no-dereference")
// .short("P") // .short('P')
// .long("no-dereference") // .long("no-dereference")
// .help("don't follow any symbolic links (this is the default)") // .help("don't follow any symbolic links (this is the default)")
// ) // )
.arg( .arg(
Arg::with_name(options::BLOCK_SIZE_1M) Arg::new(options::BLOCK_SIZE_1M)
.short("m") .short('m')
.help("like --block-size=1M") .help("like --block-size=1M")
) )
.arg( .arg(
Arg::with_name(options::NULL) Arg::new(options::NULL)
.short("0") .short('0')
.long("null") .long("null")
.help("end each output line with 0 byte rather than newline") .help("end each output line with 0 byte rather than newline")
) )
.arg( .arg(
Arg::with_name(options::SEPARATE_DIRS) Arg::new(options::SEPARATE_DIRS)
.short("S") .short('S')
.long("separate-dirs") .long("separate-dirs")
.help("do not include size of subdirectories") .help("do not include size of subdirectories")
) )
.arg( .arg(
Arg::with_name(options::SUMMARIZE) Arg::new(options::SUMMARIZE)
.short("s") .short('s')
.long("summarize") .long("summarize")
.help("display only a total for each argument") .help("display only a total for each argument")
) )
.arg( .arg(
Arg::with_name(options::SI) Arg::new(options::SI)
.long(options::SI) .long(options::SI)
.help("like -h, but use powers of 1000 not 1024") .help("like -h, but use powers of 1000 not 1024")
) )
.arg( .arg(
Arg::with_name(options::ONE_FILE_SYSTEM) Arg::new(options::ONE_FILE_SYSTEM)
.short("x") .short('x')
.long(options::ONE_FILE_SYSTEM) .long(options::ONE_FILE_SYSTEM)
.help("skip directories on different file systems") .help("skip directories on different file systems")
) )
.arg( .arg(
Arg::with_name(options::THRESHOLD) Arg::new(options::THRESHOLD)
.short("t") .short('t')
.long(options::THRESHOLD) .long(options::THRESHOLD)
.alias("th") .alias("th")
.value_name("SIZE") .value_name("SIZE")
@ -761,20 +761,20 @@ pub fn uu_app() -> App<'static, 'static> {
or entries greater than SIZE if negative") or entries greater than SIZE if negative")
) )
// .arg( // .arg(
// Arg::with_name("") // Arg::new("")
// .short("x") // .short('x')
// .long("exclude-from") // .long("exclude-from")
// .value_name("FILE") // .value_name("FILE")
// .help("exclude files that match any pattern in FILE") // .help("exclude files that match any pattern in FILE")
// ) // )
// .arg( // .arg(
// Arg::with_name("exclude") // Arg::new("exclude")
// .long("exclude") // .long("exclude")
// .value_name("PATTERN") // .value_name("PATTERN")
// .help("exclude files that match PATTERN") // .help("exclude files that match PATTERN")
// ) // )
.arg( .arg(
Arg::with_name(options::TIME) Arg::new(options::TIME)
.long(options::TIME) .long(options::TIME)
.value_name("WORD") .value_name("WORD")
.require_equals(true) .require_equals(true)
@ -787,7 +787,7 @@ pub fn uu_app() -> App<'static, 'static> {
) )
) )
.arg( .arg(
Arg::with_name(options::TIME_STYLE) Arg::new(options::TIME_STYLE)
.long(options::TIME_STYLE) .long(options::TIME_STYLE)
.value_name("STYLE") .value_name("STYLE")
.help( .help(
@ -796,9 +796,9 @@ pub fn uu_app() -> App<'static, 'static> {
) )
) )
.arg( .arg(
Arg::with_name(options::FILE) Arg::new(options::FILE)
.hidden(true) .hide(true)
.multiple(true) .multiple_occurrences(true)
) )
} }