diff --git a/Cargo.lock b/Cargo.lock index b12984b96..e618372bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,7 +96,7 @@ dependencies = [ "bitflags", "cexpr", "clang-sys", - "clap", + "clap 2.34.0", "env_logger 0.9.0", "lazy_static", "lazycell", @@ -235,13 +235,38 @@ dependencies = [ "ansi_term", "atty", "bitflags", - "strsim", - "term_size", + "strsim 0.8.0", "textwrap 0.11.0", "unicode-width", "vec_map", ] +[[package]] +name = "clap" +version = "3.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a30c3bf9ff12dfe5dae53f0a96e0febcd18420d1c0e7fad77796d9d5c4b5375" +dependencies = [ + "atty", + "bitflags", + "indexmap", + "lazy_static", + "os_str_bytes", + "strsim 0.10.0", + "termcolor", + "terminal_size", + "textwrap 0.14.2", +] + +[[package]] +name = "clap_complete" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d044e9db8cd0f68191becdeb5246b7462e4cf0c069b19ae00d1bf3fa9889498d" +dependencies = [ + "clap 3.0.10", +] + [[package]] name = "cloudabi" version = "0.0.3" @@ -274,11 +299,12 @@ dependencies = [ [[package]] name = "coreutils" -version = "0.0.9" +version = "0.0.12" dependencies = [ "atty", "chrono", - "clap", + "clap 3.0.10", + "clap_complete", "conv", "filetime", "glob", @@ -843,6 +869,12 @@ dependencies = [ "ahash", ] +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" + [[package]] name = "heck" version = "0.3.3" @@ -890,6 +922,16 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46dbcb333e86939721589d25a3557e180b52778cb33c7fdfe9e0158ff790d5ec" +[[package]] +name = "indexmap" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" +dependencies = [ + "autocfg", + "hashbrown 0.11.2", +] + [[package]] name = "instant" version = "0.1.12" @@ -947,9 +989,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.112" +version = "0.2.113" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" +checksum = "eef78b64d87775463c549fbd80e19249ef436ea3bf1de2a1eb7e717ec7fab1e9" [[package]] name = "libloading" @@ -1221,7 +1263,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c672c7ad9ec066e428c00eb917124a06f08db19e2584de982cc34b1f4c12485" dependencies = [ "dlv-list", - "hashbrown", + "hashbrown 0.9.1", ] [[package]] @@ -1233,6 +1275,15 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "os_str_bytes" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64" +dependencies = [ + "memchr 2.4.1", +] + [[package]] name = "ouroboros" version = "0.10.1" @@ -1719,18 +1770,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.133" +version = "1.0.134" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97565067517b60e2d1ea8b268e59ce036de907ac523ad83a0475da04e818989a" +checksum = "96b3c34c1690edf8174f5b289a336ab03f568a4460d8c6df75f2f3a692b3bc6a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.133" +version = "1.0.134" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed201699328568d8d08208fdd080e3ff594e6c422e438b6705905da01005d537" +checksum = "784ed1fbfa13fe191077537b0d70ec8ad1e903cfe04831da608aa36457cb653d" dependencies = [ "proc-macro2", "quote 1.0.14", @@ -1827,9 +1878,9 @@ checksum = "f67ad224767faa3c7d8b6d91985b78e70a1324408abcb1cfcc2be4c06bc06043" [[package]] name = "socket2" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dc90fe6c7be1a323296982db1836d1ea9e47b6839496dde9a541bc496df3516" +checksum = "0f82496b90c36d70af5fcd482edaa2e0bd16fade569de1330405fecbbdac736b" dependencies = [ "libc", "winapi 0.3.9", @@ -1847,6 +1898,12 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + [[package]] name = "strum" version = "0.21.0" @@ -1867,9 +1924,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.85" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a684ac3dcd8913827e18cd09a68384ee66c1de24157e3c556c9ab16d85695fb7" +checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" dependencies = [ "proc-macro2", "quote 1.0.14", @@ -1899,16 +1956,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "term_size" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e4129646ca0ed8f45d09b929036bafad5377103edd06e50bf574b353d2b08d9" -dependencies = [ - "libc", - "winapi 0.3.9", -] - [[package]] name = "termcolor" version = "1.1.2" @@ -1959,7 +2006,6 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" dependencies = [ - "term_size", "unicode-width", ] @@ -2093,9 +2139,9 @@ checksum = "7cf7d77f457ef8dfa11e4cd5933c5ddb5dc52a94664071951219a97710f0a32b" [[package]] name = "uu_arch" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "platform-info", "uucore", "uucore_procs", @@ -2103,18 +2149,17 @@ dependencies = [ [[package]] name = "uu_base32" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "uucore", "uucore_procs", ] [[package]] name = "uu_base64" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", "uu_base32", "uucore", "uucore_procs", @@ -2122,18 +2167,18 @@ dependencies = [ [[package]] name = "uu_basename" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "uucore", "uucore_procs", ] [[package]] name = "uu_basenc" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "uu_base32", "uucore", "uucore_procs", @@ -2141,10 +2186,10 @@ dependencies = [ [[package]] name = "uu_cat" -version = "0.0.9" +version = "0.0.12" dependencies = [ "atty", - "clap", + "clap 3.0.10", "nix 0.23.1", "thiserror", "unix_socket", @@ -2155,9 +2200,9 @@ dependencies = [ [[package]] name = "uu_chcon" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "fts-sys", "libc", "selinux", @@ -2168,18 +2213,18 @@ dependencies = [ [[package]] name = "uu_chgrp" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "uucore", "uucore_procs", ] [[package]] name = "uu_chmod" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "libc", "uucore", "uucore_procs", @@ -2188,27 +2233,27 @@ dependencies = [ [[package]] name = "uu_chown" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "uucore", "uucore_procs", ] [[package]] name = "uu_chroot" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "uucore", "uucore_procs", ] [[package]] name = "uu_cksum" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "libc", "uucore", "uucore_procs", @@ -2216,9 +2261,9 @@ dependencies = [ [[package]] name = "uu_comm" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "libc", "uucore", "uucore_procs", @@ -2226,9 +2271,9 @@ dependencies = [ [[package]] name = "uu_cp" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "exacl", "filetime", "ioctl-sys", @@ -2244,9 +2289,9 @@ dependencies = [ [[package]] name = "uu_csplit" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "regex", "thiserror", "uucore", @@ -2255,11 +2300,11 @@ dependencies = [ [[package]] name = "uu_cut" -version = "0.0.9" +version = "0.0.12" dependencies = [ "atty", "bstr", - "clap", + "clap 3.0.10", "memchr 2.4.1", "uucore", "uucore_procs", @@ -2267,10 +2312,10 @@ dependencies = [ [[package]] name = "uu_date" -version = "0.0.9" +version = "0.0.12" dependencies = [ "chrono", - "clap", + "clap 3.0.10", "libc", "uucore", "uucore_procs", @@ -2279,10 +2324,10 @@ dependencies = [ [[package]] name = "uu_dd" -version = "0.0.9" +version = "0.0.12" dependencies = [ "byte-unit", - "clap", + "clap 3.0.10", "gcd", "libc", "signal-hook", @@ -2293,9 +2338,9 @@ dependencies = [ [[package]] name = "uu_df" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "number_prefix", "uucore", "uucore_procs", @@ -2303,9 +2348,9 @@ dependencies = [ [[package]] name = "uu_dircolors" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "glob", "uucore", "uucore_procs", @@ -2313,9 +2358,9 @@ dependencies = [ [[package]] name = "uu_dirname" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "libc", "uucore", "uucore_procs", @@ -2323,10 +2368,10 @@ dependencies = [ [[package]] name = "uu_du" -version = "0.0.9" +version = "0.0.12" dependencies = [ "chrono", - "clap", + "clap 3.0.10", "uucore", "uucore_procs", "winapi 0.3.9", @@ -2334,18 +2379,18 @@ dependencies = [ [[package]] name = "uu_echo" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "uucore", "uucore_procs", ] [[package]] name = "uu_env" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "libc", "rust-ini", "uucore", @@ -2354,9 +2399,9 @@ dependencies = [ [[package]] name = "uu_expand" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "unicode-width", "uucore", "uucore_procs", @@ -2364,9 +2409,9 @@ dependencies = [ [[package]] name = "uu_expr" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "libc", "num-bigint", "num-traits", @@ -2377,9 +2422,9 @@ dependencies = [ [[package]] name = "uu_factor" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "coz", "num-traits", "paste 0.1.18", @@ -2392,18 +2437,18 @@ dependencies = [ [[package]] name = "uu_false" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "uucore", "uucore_procs", ] [[package]] name = "uu_fmt" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "libc", "unicode-width", "uucore", @@ -2412,28 +2457,28 @@ dependencies = [ [[package]] name = "uu_fold" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "uucore", "uucore_procs", ] [[package]] name = "uu_groups" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "uucore", "uucore_procs", ] [[package]] name = "uu_hashsum" -version = "0.0.9" +version = "0.0.12" dependencies = [ "blake2b_simd", - "clap", + "clap 3.0.10", "digest", "hex", "libc", @@ -2450,9 +2495,9 @@ dependencies = [ [[package]] name = "uu_head" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "memchr 2.4.1", "uucore", "uucore_procs", @@ -2460,9 +2505,9 @@ dependencies = [ [[package]] name = "uu_hostid" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "libc", "uucore", "uucore_procs", @@ -2470,9 +2515,9 @@ dependencies = [ [[package]] name = "uu_hostname" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "hostname", "libc", "uucore", @@ -2482,9 +2527,9 @@ dependencies = [ [[package]] name = "uu_id" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "selinux", "uucore", "uucore_procs", @@ -2492,9 +2537,9 @@ dependencies = [ [[package]] name = "uu_install" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "file_diff", "filetime", "libc", @@ -2505,18 +2550,18 @@ dependencies = [ [[package]] name = "uu_join" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "uucore", "uucore_procs", ] [[package]] name = "uu_kill" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "libc", "uucore", "uucore_procs", @@ -2524,9 +2569,9 @@ dependencies = [ [[package]] name = "uu_link" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "libc", "uucore", "uucore_procs", @@ -2534,9 +2579,9 @@ dependencies = [ [[package]] name = "uu_ln" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "libc", "uucore", "uucore_procs", @@ -2544,9 +2589,9 @@ dependencies = [ [[package]] name = "uu_logname" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "libc", "uucore", "uucore_procs", @@ -2554,11 +2599,11 @@ dependencies = [ [[package]] name = "uu_ls" -version = "0.0.9" +version = "0.0.12" dependencies = [ "atty", "chrono", - "clap", + "clap 3.0.10", "glob", "lazy_static", "lscolors", @@ -2574,9 +2619,9 @@ dependencies = [ [[package]] name = "uu_mkdir" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "libc", "uucore", "uucore_procs", @@ -2584,9 +2629,9 @@ dependencies = [ [[package]] name = "uu_mkfifo" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "libc", "uucore", "uucore_procs", @@ -2594,9 +2639,9 @@ dependencies = [ [[package]] name = "uu_mknod" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "libc", "uucore", "uucore_procs", @@ -2604,9 +2649,9 @@ dependencies = [ [[package]] name = "uu_mktemp" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "rand 0.5.6", "tempfile", "uucore", @@ -2615,10 +2660,10 @@ dependencies = [ [[package]] name = "uu_more" -version = "0.0.9" +version = "0.0.12" dependencies = [ "atty", - "clap", + "clap 3.0.10", "crossterm", "nix 0.23.1", "redox_syscall", @@ -2631,9 +2676,9 @@ dependencies = [ [[package]] name = "uu_mv" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "fs_extra", "uucore", "uucore_procs", @@ -2641,9 +2686,9 @@ dependencies = [ [[package]] name = "uu_nice" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "libc", "nix 0.23.1", "uucore", @@ -2652,10 +2697,10 @@ dependencies = [ [[package]] name = "uu_nl" -version = "0.0.9" +version = "0.0.12" dependencies = [ "aho-corasick", - "clap", + "clap 3.0.10", "libc", "memchr 2.4.1", "regex", @@ -2666,10 +2711,10 @@ dependencies = [ [[package]] name = "uu_nohup" -version = "0.0.9" +version = "0.0.12" dependencies = [ "atty", - "clap", + "clap 3.0.10", "libc", "uucore", "uucore_procs", @@ -2677,9 +2722,9 @@ dependencies = [ [[package]] name = "uu_nproc" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "libc", "num_cpus", "uucore", @@ -2688,19 +2733,19 @@ dependencies = [ [[package]] name = "uu_numfmt" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "uucore", "uucore_procs", ] [[package]] name = "uu_od" -version = "0.0.9" +version = "0.0.12" dependencies = [ "byteorder", - "clap", + "clap 3.0.10", "half", "libc", "uucore", @@ -2709,18 +2754,18 @@ dependencies = [ [[package]] name = "uu_paste" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "uucore", "uucore_procs", ] [[package]] name = "uu_pathchk" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "libc", "uucore", "uucore_procs", @@ -2728,19 +2773,19 @@ dependencies = [ [[package]] name = "uu_pinky" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "uucore", "uucore_procs", ] [[package]] name = "uu_pr" -version = "0.0.9" +version = "0.0.12" dependencies = [ "chrono", - "clap", + "clap 3.0.10", "getopts", "itertools 0.10.3", "quick-error 2.0.1", @@ -2751,18 +2796,18 @@ dependencies = [ [[package]] name = "uu_printenv" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "uucore", "uucore_procs", ] [[package]] name = "uu_printf" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "itertools 0.8.2", "uucore", "uucore_procs", @@ -2770,10 +2815,10 @@ dependencies = [ [[package]] name = "uu_ptx" -version = "0.0.9" +version = "0.0.12" dependencies = [ "aho-corasick", - "clap", + "clap 3.0.10", "libc", "memchr 2.4.1", "regex", @@ -2784,18 +2829,18 @@ dependencies = [ [[package]] name = "uu_pwd" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "uucore", "uucore_procs", ] [[package]] name = "uu_readlink" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "libc", "uucore", "uucore_procs", @@ -2803,27 +2848,27 @@ dependencies = [ [[package]] name = "uu_realpath" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "uucore", "uucore_procs", ] [[package]] name = "uu_relpath" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "uucore", "uucore_procs", ] [[package]] name = "uu_rm" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "remove_dir_all", "uucore", "uucore_procs", @@ -2833,9 +2878,9 @@ dependencies = [ [[package]] name = "uu_rmdir" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "libc", "uucore", "uucore_procs", @@ -2843,9 +2888,9 @@ dependencies = [ [[package]] name = "uu_runcon" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "fts-sys", "libc", "selinux", @@ -2856,10 +2901,10 @@ dependencies = [ [[package]] name = "uu_seq" -version = "0.0.9" +version = "0.0.12" dependencies = [ "bigdecimal", - "clap", + "clap 3.0.10", "num-bigint", "num-traits", "uucore", @@ -2868,9 +2913,9 @@ dependencies = [ [[package]] name = "uu_shred" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "libc", "rand 0.7.3", "uucore", @@ -2879,9 +2924,9 @@ dependencies = [ [[package]] name = "uu_shuf" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "rand 0.5.6", "uucore", "uucore_procs", @@ -2889,19 +2934,19 @@ dependencies = [ [[package]] name = "uu_sleep" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "uucore", "uucore_procs", ] [[package]] name = "uu_sort" -version = "0.0.9" +version = "0.0.12" dependencies = [ "binary-heap-plus", - "clap", + "clap 3.0.10", "compare", "ctrlc", "fnv", @@ -2918,27 +2963,27 @@ dependencies = [ [[package]] name = "uu_split" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "uucore", "uucore_procs", ] [[package]] name = "uu_stat" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "uucore", "uucore_procs", ] [[package]] name = "uu_stdbuf" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "tempfile", "uu_stdbuf_libstdbuf", "uucore", @@ -2947,7 +2992,7 @@ dependencies = [ [[package]] name = "uu_stdbuf_libstdbuf" -version = "0.0.9" +version = "0.0.12" dependencies = [ "cpp", "cpp_build", @@ -2958,18 +3003,18 @@ dependencies = [ [[package]] name = "uu_sum" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "uucore", "uucore_procs", ] [[package]] name = "uu_sync" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "libc", "uucore", "uucore_procs", @@ -2978,9 +3023,9 @@ dependencies = [ [[package]] name = "uu_tac" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "memchr 2.4.1", "memmap2", "regex", @@ -2990,9 +3035,9 @@ dependencies = [ [[package]] name = "uu_tail" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "libc", "nix 0.23.1", "redox_syscall", @@ -3003,9 +3048,9 @@ dependencies = [ [[package]] name = "uu_tee" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "libc", "retain_mut", "uucore", @@ -3014,9 +3059,9 @@ dependencies = [ [[package]] name = "uu_test" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "libc", "redox_syscall", "uucore", @@ -3025,9 +3070,9 @@ dependencies = [ [[package]] name = "uu_timeout" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "libc", "nix 0.23.1", "uucore", @@ -3036,9 +3081,9 @@ dependencies = [ [[package]] name = "uu_touch" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "filetime", "time", "uucore", @@ -3047,9 +3092,9 @@ dependencies = [ [[package]] name = "uu_tr" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "nom", "uucore", "uucore_procs", @@ -3057,37 +3102,37 @@ dependencies = [ [[package]] name = "uu_true" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "uucore", "uucore_procs", ] [[package]] name = "uu_truncate" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "uucore", "uucore_procs", ] [[package]] name = "uu_tsort" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "uucore", "uucore_procs", ] [[package]] name = "uu_tty" -version = "0.0.9" +version = "0.0.12" dependencies = [ "atty", - "clap", + "clap 3.0.10", "libc", "uucore", "uucore_procs", @@ -3095,9 +3140,9 @@ dependencies = [ [[package]] name = "uu_uname" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "platform-info", "uucore", "uucore_procs", @@ -3105,9 +3150,9 @@ dependencies = [ [[package]] name = "uu_unexpand" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "unicode-width", "uucore", "uucore_procs", @@ -3115,9 +3160,9 @@ dependencies = [ [[package]] name = "uu_uniq" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "strum", "strum_macros", "uucore", @@ -3126,38 +3171,38 @@ dependencies = [ [[package]] name = "uu_unlink" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "uucore", "uucore_procs", ] [[package]] name = "uu_uptime" -version = "0.0.9" +version = "0.0.12" dependencies = [ "chrono", - "clap", + "clap 3.0.10", "uucore", "uucore_procs", ] [[package]] name = "uu_users" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "uucore", "uucore_procs", ] [[package]] name = "uu_wc" -version = "0.0.9" +version = "0.0.12" dependencies = [ "bytecount", - "clap", + "clap 3.0.10", "libc", "nix 0.23.1", "unicode-width", @@ -3168,18 +3213,18 @@ dependencies = [ [[package]] name = "uu_who" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "uucore", "uucore_procs", ] [[package]] name = "uu_whoami" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "libc", "uucore", "uucore_procs", @@ -3188,9 +3233,9 @@ dependencies = [ [[package]] name = "uu_yes" -version = "0.0.9" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "nix 0.23.1", "uucore", "uucore_procs", @@ -3198,9 +3243,9 @@ dependencies = [ [[package]] name = "uucore" -version = "0.0.11" +version = "0.0.12" dependencies = [ - "clap", + "clap 3.0.10", "data-encoding", "data-encoding-macro", "dns-lookup", @@ -3222,7 +3267,7 @@ dependencies = [ [[package]] name = "uucore_procs" -version = "0.0.8" +version = "0.0.12" dependencies = [ "proc-macro2", "quote 1.0.14", diff --git a/Cargo.toml b/Cargo.toml index 07da3b2b0..14265524f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ [package] name = "coreutils" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "coreutils ~ GNU coreutils (updated); implemented as universal (cross-platform) utils, written in Rust" @@ -244,113 +244,114 @@ test = [ "uu_test" ] [workspace] [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap_complete = "3.0" lazy_static = { version="1.3" } textwrap = { version="0.14", features=["terminal_size"] } uucore = { version=">=0.0.11", package="uucore", path="src/uucore" } selinux = { version="0.2.3", optional = true } # * uutils -uu_test = { optional=true, version="0.0.9", package="uu_test", path="src/uu/test" } +uu_test = { optional=true, version="0.0.12", package="uu_test", path="src/uu/test" } # -arch = { optional=true, version="0.0.9", package="uu_arch", path="src/uu/arch" } -base32 = { optional=true, version="0.0.9", package="uu_base32", path="src/uu/base32" } -base64 = { optional=true, version="0.0.9", package="uu_base64", path="src/uu/base64" } -basename = { optional=true, version="0.0.9", package="uu_basename", path="src/uu/basename" } -basenc = { optional=true, version="0.0.9", package="uu_basenc", path="src/uu/basenc" } -cat = { optional=true, version="0.0.9", package="uu_cat", path="src/uu/cat" } -chcon = { optional=true, version="0.0.9", package="uu_chcon", path="src/uu/chcon" } -chgrp = { optional=true, version="0.0.9", package="uu_chgrp", path="src/uu/chgrp" } -chmod = { optional=true, version="0.0.9", package="uu_chmod", path="src/uu/chmod" } -chown = { optional=true, version="0.0.9", package="uu_chown", path="src/uu/chown" } -chroot = { optional=true, version="0.0.9", package="uu_chroot", path="src/uu/chroot" } -cksum = { optional=true, version="0.0.9", package="uu_cksum", path="src/uu/cksum" } -comm = { optional=true, version="0.0.9", package="uu_comm", path="src/uu/comm" } -cp = { optional=true, version="0.0.9", package="uu_cp", path="src/uu/cp" } -csplit = { optional=true, version="0.0.9", package="uu_csplit", path="src/uu/csplit" } -cut = { optional=true, version="0.0.9", package="uu_cut", path="src/uu/cut" } -date = { optional=true, version="0.0.9", package="uu_date", path="src/uu/date" } -dd = { optional=true, version="0.0.9", package="uu_dd", path="src/uu/dd" } -df = { optional=true, version="0.0.9", package="uu_df", path="src/uu/df" } -dircolors= { optional=true, version="0.0.9", package="uu_dircolors", path="src/uu/dircolors" } -dirname = { optional=true, version="0.0.9", package="uu_dirname", path="src/uu/dirname" } -du = { optional=true, version="0.0.9", package="uu_du", path="src/uu/du" } -echo = { optional=true, version="0.0.9", package="uu_echo", path="src/uu/echo" } -env = { optional=true, version="0.0.9", package="uu_env", path="src/uu/env" } -expand = { optional=true, version="0.0.9", package="uu_expand", path="src/uu/expand" } -expr = { optional=true, version="0.0.9", package="uu_expr", path="src/uu/expr" } -factor = { optional=true, version="0.0.9", package="uu_factor", path="src/uu/factor" } -false = { optional=true, version="0.0.9", package="uu_false", path="src/uu/false" } -fmt = { optional=true, version="0.0.9", package="uu_fmt", path="src/uu/fmt" } -fold = { optional=true, version="0.0.9", package="uu_fold", path="src/uu/fold" } -groups = { optional=true, version="0.0.9", package="uu_groups", path="src/uu/groups" } -hashsum = { optional=true, version="0.0.9", package="uu_hashsum", path="src/uu/hashsum" } -head = { optional=true, version="0.0.9", package="uu_head", path="src/uu/head" } -hostid = { optional=true, version="0.0.9", package="uu_hostid", path="src/uu/hostid" } -hostname = { optional=true, version="0.0.9", package="uu_hostname", path="src/uu/hostname" } -id = { optional=true, version="0.0.9", package="uu_id", path="src/uu/id" } -install = { optional=true, version="0.0.9", package="uu_install", path="src/uu/install" } -join = { optional=true, version="0.0.9", package="uu_join", path="src/uu/join" } -kill = { optional=true, version="0.0.9", package="uu_kill", path="src/uu/kill" } -link = { optional=true, version="0.0.9", package="uu_link", path="src/uu/link" } -ln = { optional=true, version="0.0.9", package="uu_ln", path="src/uu/ln" } -ls = { optional=true, version="0.0.9", package="uu_ls", path="src/uu/ls" } -logname = { optional=true, version="0.0.9", package="uu_logname", path="src/uu/logname" } -mkdir = { optional=true, version="0.0.9", package="uu_mkdir", path="src/uu/mkdir" } -mkfifo = { optional=true, version="0.0.9", package="uu_mkfifo", path="src/uu/mkfifo" } -mknod = { optional=true, version="0.0.9", package="uu_mknod", path="src/uu/mknod" } -mktemp = { optional=true, version="0.0.9", package="uu_mktemp", path="src/uu/mktemp" } -more = { optional=true, version="0.0.9", package="uu_more", path="src/uu/more" } -mv = { optional=true, version="0.0.9", package="uu_mv", path="src/uu/mv" } -nice = { optional=true, version="0.0.9", package="uu_nice", path="src/uu/nice" } -nl = { optional=true, version="0.0.9", package="uu_nl", path="src/uu/nl" } -nohup = { optional=true, version="0.0.9", package="uu_nohup", path="src/uu/nohup" } -nproc = { optional=true, version="0.0.9", package="uu_nproc", path="src/uu/nproc" } -numfmt = { optional=true, version="0.0.9", package="uu_numfmt", path="src/uu/numfmt" } -od = { optional=true, version="0.0.9", package="uu_od", path="src/uu/od" } -paste = { optional=true, version="0.0.9", package="uu_paste", path="src/uu/paste" } -pathchk = { optional=true, version="0.0.9", package="uu_pathchk", path="src/uu/pathchk" } -pinky = { optional=true, version="0.0.9", package="uu_pinky", path="src/uu/pinky" } -pr = { optional=true, version="0.0.9", package="uu_pr", path="src/uu/pr" } -printenv = { optional=true, version="0.0.9", package="uu_printenv", path="src/uu/printenv" } -printf = { optional=true, version="0.0.9", package="uu_printf", path="src/uu/printf" } -ptx = { optional=true, version="0.0.9", package="uu_ptx", path="src/uu/ptx" } -pwd = { optional=true, version="0.0.9", package="uu_pwd", path="src/uu/pwd" } -readlink = { optional=true, version="0.0.9", package="uu_readlink", path="src/uu/readlink" } -realpath = { optional=true, version="0.0.9", package="uu_realpath", path="src/uu/realpath" } -relpath = { optional=true, version="0.0.9", package="uu_relpath", path="src/uu/relpath" } -rm = { optional=true, version="0.0.9", package="uu_rm", path="src/uu/rm" } -rmdir = { optional=true, version="0.0.9", package="uu_rmdir", path="src/uu/rmdir" } -runcon = { optional=true, version="0.0.9", package="uu_runcon", path="src/uu/runcon" } -seq = { optional=true, version="0.0.9", package="uu_seq", path="src/uu/seq" } -shred = { optional=true, version="0.0.9", package="uu_shred", path="src/uu/shred" } -shuf = { optional=true, version="0.0.9", package="uu_shuf", path="src/uu/shuf" } -sleep = { optional=true, version="0.0.9", package="uu_sleep", path="src/uu/sleep" } -sort = { optional=true, version="0.0.9", package="uu_sort", path="src/uu/sort" } -split = { optional=true, version="0.0.9", package="uu_split", path="src/uu/split" } -stat = { optional=true, version="0.0.9", package="uu_stat", path="src/uu/stat" } -stdbuf = { optional=true, version="0.0.9", package="uu_stdbuf", path="src/uu/stdbuf" } -sum = { optional=true, version="0.0.9", package="uu_sum", path="src/uu/sum" } -sync = { optional=true, version="0.0.9", package="uu_sync", path="src/uu/sync" } -tac = { optional=true, version="0.0.9", package="uu_tac", path="src/uu/tac" } -tail = { optional=true, version="0.0.9", package="uu_tail", path="src/uu/tail" } -tee = { optional=true, version="0.0.9", package="uu_tee", path="src/uu/tee" } -timeout = { optional=true, version="0.0.9", package="uu_timeout", path="src/uu/timeout" } -touch = { optional=true, version="0.0.9", package="uu_touch", path="src/uu/touch" } -tr = { optional=true, version="0.0.9", package="uu_tr", path="src/uu/tr" } -true = { optional=true, version="0.0.9", package="uu_true", path="src/uu/true" } -truncate = { optional=true, version="0.0.9", package="uu_truncate", path="src/uu/truncate" } -tsort = { optional=true, version="0.0.9", package="uu_tsort", path="src/uu/tsort" } -tty = { optional=true, version="0.0.9", package="uu_tty", path="src/uu/tty" } -uname = { optional=true, version="0.0.9", package="uu_uname", path="src/uu/uname" } -unexpand = { optional=true, version="0.0.9", package="uu_unexpand", path="src/uu/unexpand" } -uniq = { optional=true, version="0.0.9", package="uu_uniq", path="src/uu/uniq" } -unlink = { optional=true, version="0.0.9", package="uu_unlink", path="src/uu/unlink" } -uptime = { optional=true, version="0.0.9", package="uu_uptime", path="src/uu/uptime" } -users = { optional=true, version="0.0.9", package="uu_users", path="src/uu/users" } -wc = { optional=true, version="0.0.9", package="uu_wc", path="src/uu/wc" } -who = { optional=true, version="0.0.9", package="uu_who", path="src/uu/who" } -whoami = { optional=true, version="0.0.9", package="uu_whoami", path="src/uu/whoami" } -yes = { optional=true, version="0.0.9", package="uu_yes", path="src/uu/yes" } +arch = { optional=true, version="0.0.12", package="uu_arch", path="src/uu/arch" } +base32 = { optional=true, version="0.0.12", package="uu_base32", path="src/uu/base32" } +base64 = { optional=true, version="0.0.12", package="uu_base64", path="src/uu/base64" } +basename = { optional=true, version="0.0.12", package="uu_basename", path="src/uu/basename" } +basenc = { optional=true, version="0.0.12", package="uu_basenc", path="src/uu/basenc" } +cat = { optional=true, version="0.0.12", package="uu_cat", path="src/uu/cat" } +chcon = { optional=true, version="0.0.12", package="uu_chcon", path="src/uu/chcon" } +chgrp = { optional=true, version="0.0.12", package="uu_chgrp", path="src/uu/chgrp" } +chmod = { optional=true, version="0.0.12", package="uu_chmod", path="src/uu/chmod" } +chown = { optional=true, version="0.0.12", package="uu_chown", path="src/uu/chown" } +chroot = { optional=true, version="0.0.12", package="uu_chroot", path="src/uu/chroot" } +cksum = { optional=true, version="0.0.12", package="uu_cksum", path="src/uu/cksum" } +comm = { optional=true, version="0.0.12", package="uu_comm", path="src/uu/comm" } +cp = { optional=true, version="0.0.12", package="uu_cp", path="src/uu/cp" } +csplit = { optional=true, version="0.0.12", package="uu_csplit", path="src/uu/csplit" } +cut = { optional=true, version="0.0.12", package="uu_cut", path="src/uu/cut" } +date = { optional=true, version="0.0.12", package="uu_date", path="src/uu/date" } +dd = { optional=true, version="0.0.12", package="uu_dd", path="src/uu/dd" } +df = { optional=true, version="0.0.12", package="uu_df", path="src/uu/df" } +dircolors= { optional=true, version="0.0.12", package="uu_dircolors", path="src/uu/dircolors" } +dirname = { optional=true, version="0.0.12", package="uu_dirname", path="src/uu/dirname" } +du = { optional=true, version="0.0.12", package="uu_du", path="src/uu/du" } +echo = { optional=true, version="0.0.12", package="uu_echo", path="src/uu/echo" } +env = { optional=true, version="0.0.12", package="uu_env", path="src/uu/env" } +expand = { optional=true, version="0.0.12", package="uu_expand", path="src/uu/expand" } +expr = { optional=true, version="0.0.12", package="uu_expr", path="src/uu/expr" } +factor = { optional=true, version="0.0.12", package="uu_factor", path="src/uu/factor" } +false = { optional=true, version="0.0.12", package="uu_false", path="src/uu/false" } +fmt = { optional=true, version="0.0.12", package="uu_fmt", path="src/uu/fmt" } +fold = { optional=true, version="0.0.12", package="uu_fold", path="src/uu/fold" } +groups = { optional=true, version="0.0.12", package="uu_groups", path="src/uu/groups" } +hashsum = { optional=true, version="0.0.12", package="uu_hashsum", path="src/uu/hashsum" } +head = { optional=true, version="0.0.12", package="uu_head", path="src/uu/head" } +hostid = { optional=true, version="0.0.12", package="uu_hostid", path="src/uu/hostid" } +hostname = { optional=true, version="0.0.12", package="uu_hostname", path="src/uu/hostname" } +id = { optional=true, version="0.0.12", package="uu_id", path="src/uu/id" } +install = { optional=true, version="0.0.12", package="uu_install", path="src/uu/install" } +join = { optional=true, version="0.0.12", package="uu_join", path="src/uu/join" } +kill = { optional=true, version="0.0.12", package="uu_kill", path="src/uu/kill" } +link = { optional=true, version="0.0.12", package="uu_link", path="src/uu/link" } +ln = { optional=true, version="0.0.12", package="uu_ln", path="src/uu/ln" } +ls = { optional=true, version="0.0.12", package="uu_ls", path="src/uu/ls" } +logname = { optional=true, version="0.0.12", package="uu_logname", path="src/uu/logname" } +mkdir = { optional=true, version="0.0.12", package="uu_mkdir", path="src/uu/mkdir" } +mkfifo = { optional=true, version="0.0.12", package="uu_mkfifo", path="src/uu/mkfifo" } +mknod = { optional=true, version="0.0.12", package="uu_mknod", path="src/uu/mknod" } +mktemp = { optional=true, version="0.0.12", package="uu_mktemp", path="src/uu/mktemp" } +more = { optional=true, version="0.0.12", package="uu_more", path="src/uu/more" } +mv = { optional=true, version="0.0.12", package="uu_mv", path="src/uu/mv" } +nice = { optional=true, version="0.0.12", package="uu_nice", path="src/uu/nice" } +nl = { optional=true, version="0.0.12", package="uu_nl", path="src/uu/nl" } +nohup = { optional=true, version="0.0.12", package="uu_nohup", path="src/uu/nohup" } +nproc = { optional=true, version="0.0.12", package="uu_nproc", path="src/uu/nproc" } +numfmt = { optional=true, version="0.0.12", package="uu_numfmt", path="src/uu/numfmt" } +od = { optional=true, version="0.0.12", package="uu_od", path="src/uu/od" } +paste = { optional=true, version="0.0.12", package="uu_paste", path="src/uu/paste" } +pathchk = { optional=true, version="0.0.12", package="uu_pathchk", path="src/uu/pathchk" } +pinky = { optional=true, version="0.0.12", package="uu_pinky", path="src/uu/pinky" } +pr = { optional=true, version="0.0.12", package="uu_pr", path="src/uu/pr" } +printenv = { optional=true, version="0.0.12", package="uu_printenv", path="src/uu/printenv" } +printf = { optional=true, version="0.0.12", package="uu_printf", path="src/uu/printf" } +ptx = { optional=true, version="0.0.12", package="uu_ptx", path="src/uu/ptx" } +pwd = { optional=true, version="0.0.12", package="uu_pwd", path="src/uu/pwd" } +readlink = { optional=true, version="0.0.12", package="uu_readlink", path="src/uu/readlink" } +realpath = { optional=true, version="0.0.12", package="uu_realpath", path="src/uu/realpath" } +relpath = { optional=true, version="0.0.12", package="uu_relpath", path="src/uu/relpath" } +rm = { optional=true, version="0.0.12", package="uu_rm", path="src/uu/rm" } +rmdir = { optional=true, version="0.0.12", package="uu_rmdir", path="src/uu/rmdir" } +runcon = { optional=true, version="0.0.12", package="uu_runcon", path="src/uu/runcon" } +seq = { optional=true, version="0.0.12", package="uu_seq", path="src/uu/seq" } +shred = { optional=true, version="0.0.12", package="uu_shred", path="src/uu/shred" } +shuf = { optional=true, version="0.0.12", package="uu_shuf", path="src/uu/shuf" } +sleep = { optional=true, version="0.0.12", package="uu_sleep", path="src/uu/sleep" } +sort = { optional=true, version="0.0.12", package="uu_sort", path="src/uu/sort" } +split = { optional=true, version="0.0.12", package="uu_split", path="src/uu/split" } +stat = { optional=true, version="0.0.12", package="uu_stat", path="src/uu/stat" } +stdbuf = { optional=true, version="0.0.12", package="uu_stdbuf", path="src/uu/stdbuf" } +sum = { optional=true, version="0.0.12", package="uu_sum", path="src/uu/sum" } +sync = { optional=true, version="0.0.12", package="uu_sync", path="src/uu/sync" } +tac = { optional=true, version="0.0.12", package="uu_tac", path="src/uu/tac" } +tail = { optional=true, version="0.0.12", package="uu_tail", path="src/uu/tail" } +tee = { optional=true, version="0.0.12", package="uu_tee", path="src/uu/tee" } +timeout = { optional=true, version="0.0.12", package="uu_timeout", path="src/uu/timeout" } +touch = { optional=true, version="0.0.12", package="uu_touch", path="src/uu/touch" } +tr = { optional=true, version="0.0.12", package="uu_tr", path="src/uu/tr" } +true = { optional=true, version="0.0.12", package="uu_true", path="src/uu/true" } +truncate = { optional=true, version="0.0.12", package="uu_truncate", path="src/uu/truncate" } +tsort = { optional=true, version="0.0.12", package="uu_tsort", path="src/uu/tsort" } +tty = { optional=true, version="0.0.12", package="uu_tty", path="src/uu/tty" } +uname = { optional=true, version="0.0.12", package="uu_uname", path="src/uu/uname" } +unexpand = { optional=true, version="0.0.12", package="uu_unexpand", path="src/uu/unexpand" } +uniq = { optional=true, version="0.0.12", package="uu_uniq", path="src/uu/uniq" } +unlink = { optional=true, version="0.0.12", package="uu_unlink", path="src/uu/unlink" } +uptime = { optional=true, version="0.0.12", package="uu_uptime", path="src/uu/uptime" } +users = { optional=true, version="0.0.12", package="uu_users", path="src/uu/users" } +wc = { optional=true, version="0.0.12", package="uu_wc", path="src/uu/wc" } +who = { optional=true, version="0.0.12", package="uu_who", path="src/uu/who" } +whoami = { optional=true, version="0.0.12", package="uu_whoami", path="src/uu/whoami" } +yes = { optional=true, version="0.0.12", package="uu_yes", path="src/uu/yes" } # this breaks clippy linting with: "tests/by-util/test_factor_benches.rs: No such file or directory (os error 2)" # factor_benches = { optional = true, version = "0.0.0", package = "uu_factor_benches", path = "tests/benches/factor" } diff --git a/build.rs b/build.rs index 517070fd5..ecff0f707 100644 --- a/build.rs +++ b/build.rs @@ -43,7 +43,7 @@ pub fn main() { let mut tf = File::create(Path::new(&out_dir).join("test_modules.rs")).unwrap(); mf.write_all( - "type UtilityMap = HashMap<&'static str, (fn(T) -> i32, fn() -> App<'static, 'static>)>;\n\ + "type UtilityMap = HashMap<&'static str, (fn(T) -> i32, fn() -> App<'static>)>;\n\ \n\ fn util_map() -> UtilityMap {\n\ \t#[allow(unused_mut)]\n\ diff --git a/src/bin/coreutils.rs b/src/bin/coreutils.rs index 1de1b6354..e83b6f697 100644 --- a/src/bin/coreutils.rs +++ b/src/bin/coreutils.rs @@ -5,9 +5,8 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -use clap::App; -use clap::Arg; -use clap::Shell; +use clap::{App, Arg}; +use clap_complete::Shell; use std::cmp; use std::collections::hash_map::HashMap; use std::ffi::OsStr; @@ -143,13 +142,13 @@ fn gen_completions( let matches = App::new("completion") .about("Prints completions to stdout") .arg( - Arg::with_name("utility") - .possible_values(&all_utilities) + Arg::new("utility") + .possible_values(all_utilities) .required(true), ) .arg( - Arg::with_name("shell") - .possible_values(&Shell::variants()) + Arg::new("shell") + .possible_values(Shell::possible_values()) .required(true), ) .get_matches_from(std::iter::once(OsString::from("completion")).chain(args)); @@ -165,12 +164,12 @@ fn gen_completions( let shell: Shell = shell.parse().unwrap(); let bin_name = std::env::var("PROG_PREFIX").unwrap_or_default() + utility; - app.gen_completions_to(bin_name, shell, &mut io::stdout()); + clap_complete::generate(shell, &mut app, bin_name, &mut io::stdout()); io::stdout().flush().unwrap(); process::exit(0); } -fn gen_coreutils_app(util_map: UtilityMap) -> App<'static, 'static> { +fn gen_coreutils_app(util_map: UtilityMap) -> App<'static> { let mut app = App::new("coreutils"); for (_, (_, sub_app)) in util_map { app = app.subcommand(sub_app()); diff --git a/src/uu/arch/Cargo.toml b/src/uu/arch/Cargo.toml index dab21fd1d..9a95cb7fa 100644 --- a/src/uu/arch/Cargo.toml +++ b/src/uu/arch/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_arch" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "arch ~ (uutils) display machine architecture" @@ -16,7 +16,7 @@ path = "src/arch.rs" [dependencies] platform-info = "0.2" -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/arch/src/arch.rs b/src/uu/arch/src/arch.rs index d23a11cc8..e0c004ec0 100644 --- a/src/uu/arch/src/arch.rs +++ b/src/uu/arch/src/arch.rs @@ -23,7 +23,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) diff --git a/src/uu/base32/Cargo.toml b/src/uu/base32/Cargo.toml index d553015a3..3cab8c157 100644 --- a/src/uu/base32/Cargo.toml +++ b/src/uu/base32/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_base32" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "base32 ~ (uutils) decode/encode input (base32-encoding)" @@ -15,7 +15,7 @@ edition = "2018" path = "src/base32.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features = ["encoding"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/base32/src/base32.rs b/src/uu/base32/src/base32.rs index f4b4b49de..329a4ec84 100644 --- a/src/uu/base32/src/base32.rs +++ b/src/uu/base32/src/base32.rs @@ -47,6 +47,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { ) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { base_common::base_app(ABOUT) } diff --git a/src/uu/base32/src/base_common.rs b/src/uu/base32/src/base_common.rs index b07203507..7dd4ce76b 100644 --- a/src/uu/base32/src/base_common.rs +++ b/src/uu/base32/src/base_common.rs @@ -86,33 +86,33 @@ impl Config { } pub fn parse_base_cmd_args(args: impl uucore::Args, about: &str, usage: &str) -> UResult { - let app = base_app(about).usage(usage); + let app = base_app(about).override_usage(usage); let arg_list = args .collect_str(InvalidEncodingHandling::ConvertLossy) .accept_any(); Config::from(&app.get_matches_from(arg_list)) } -pub fn base_app<'a>(about: &'a str) -> App<'static, 'a> { +pub fn base_app(about: &str) -> App { App::new(uucore::util_name()) .version(crate_version!()) .about(about) // Format arguments. .arg( - Arg::with_name(options::DECODE) - .short("d") + Arg::new(options::DECODE) + .short('d') .long(options::DECODE) .help("decode data"), ) .arg( - Arg::with_name(options::IGNORE_GARBAGE) - .short("i") + Arg::new(options::IGNORE_GARBAGE) + .short('i') .long(options::IGNORE_GARBAGE) .help("when decoding, ignore non-alphabetic characters"), ) .arg( - Arg::with_name(options::WRAP) - .short("w") + Arg::new(options::WRAP) + .short('w') .long(options::WRAP) .takes_value(true) .help( @@ -121,7 +121,7 @@ pub fn base_app<'a>(about: &'a str) -> App<'static, 'a> { ) // "multiple" arguments are used to check whether there is more than one // file passed in. - .arg(Arg::with_name(options::FILE).index(1).multiple(true)) + .arg(Arg::new(options::FILE).index(1).multiple_occurrences(true)) } pub fn get_input<'a>(config: &Config, stdin_ref: &'a Stdin) -> UResult> { diff --git a/src/uu/base64/Cargo.toml b/src/uu/base64/Cargo.toml index 9f07a7cb6..9ffedd884 100644 --- a/src/uu/base64/Cargo.toml +++ b/src/uu/base64/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_base64" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "base64 ~ (uutils) decode/encode input (base64-encoding)" @@ -15,7 +15,6 @@ edition = "2018" path = "src/base64.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features = ["encoding"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } uu_base32 = { version=">=0.0.8", package="uu_base32", path="../base32"} diff --git a/src/uu/basename/Cargo.toml b/src/uu/basename/Cargo.toml index cf6997c1a..b10188b8f 100644 --- a/src/uu/basename/Cargo.toml +++ b/src/uu/basename/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_basename" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "basename ~ (uutils) display PATHNAME with leading directory components removed" @@ -15,7 +15,7 @@ edition = "2018" path = "src/basename.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/basename/src/basename.rs b/src/uu/basename/src/basename.rs index 9f3ce3cc4..94c7e43e4 100644 --- a/src/uu/basename/src/basename.rs +++ b/src/uu/basename/src/basename.rs @@ -40,7 +40,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { // // Argument parsing // - let matches = uu_app().usage(&usage[..]).get_matches_from(args); + let matches = uu_app().override_usage(&usage[..]).get_matches_from(args); // too few arguments if !matches.is_present(options::NAME) { @@ -93,27 +93,31 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(SUMMARY) .arg( - Arg::with_name(options::MULTIPLE) - .short("a") + Arg::new(options::MULTIPLE) + .short('a') .long(options::MULTIPLE) .help("support multiple arguments and treat each as a NAME"), ) - .arg(Arg::with_name(options::NAME).multiple(true).hidden(true)) .arg( - Arg::with_name(options::SUFFIX) - .short("s") + Arg::new(options::NAME) + .multiple_occurrences(true) + .hide(true), + ) + .arg( + Arg::new(options::SUFFIX) + .short('s') .long(options::SUFFIX) .value_name("SUFFIX") .help("remove a trailing SUFFIX; implies -a"), ) .arg( - Arg::with_name(options::ZERO) - .short("z") + Arg::new(options::ZERO) + .short('z') .long(options::ZERO) .help("end each output line with NUL, not newline"), ) diff --git a/src/uu/basenc/Cargo.toml b/src/uu/basenc/Cargo.toml index ea9b2694c..b83a512f6 100644 --- a/src/uu/basenc/Cargo.toml +++ b/src/uu/basenc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_basenc" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "basenc ~ (uutils) decode/encode input" @@ -15,7 +15,7 @@ edition = "2018" path = "src/basenc.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features = ["encoding"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } uu_base32 = { version=">=0.0.8", package="uu_base32", path="../base32"} diff --git a/src/uu/basenc/src/basenc.rs b/src/uu/basenc/src/basenc.rs index e4b24c351..9f67bf488 100644 --- a/src/uu/basenc/src/basenc.rs +++ b/src/uu/basenc/src/basenc.rs @@ -45,17 +45,17 @@ fn usage() -> String { format!("{0} [OPTION]... [FILE]", uucore::execution_phrase()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { let mut app = base_common::base_app(ABOUT); for encoding in ENCODINGS { - app = app.arg(Arg::with_name(encoding.0).long(encoding.0)); + app = app.arg(Arg::new(encoding.0).long(encoding.0)); } app } fn parse_cmd_args(args: impl uucore::Args) -> UResult<(Config, Format)> { let usage = usage(); - let matches = uu_app().usage(&usage[..]).get_matches_from( + let matches = uu_app().override_usage(&usage[..]).get_matches_from( args.collect_str(InvalidEncodingHandling::ConvertLossy) .accept_any(), ); diff --git a/src/uu/cat/Cargo.toml b/src/uu/cat/Cargo.toml index 22365835a..e22fc7f32 100644 --- a/src/uu/cat/Cargo.toml +++ b/src/uu/cat/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_cat" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "cat ~ (uutils) concatenate and display input" @@ -15,7 +15,7 @@ edition = "2018" path = "src/cat.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } thiserror = "1.0" atty = "0.2" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs", "pipes"] } diff --git a/src/uu/cat/src/cat.rs b/src/uu/cat/src/cat.rs index f647906ba..f88eda28c 100644 --- a/src/uu/cat/src/cat.rs +++ b/src/uu/cat/src/cat.rs @@ -239,64 +239,68 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { cat_files(files, &options) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .name(NAME) .version(crate_version!()) - .usage(SYNTAX) + .override_usage(SYNTAX) .about(SUMMARY) - .arg(Arg::with_name(options::FILE).hidden(true).multiple(true)) .arg( - Arg::with_name(options::SHOW_ALL) - .short("A") + Arg::new(options::FILE) + .hide(true) + .multiple_occurrences(true), + ) + .arg( + Arg::new(options::SHOW_ALL) + .short('A') .long(options::SHOW_ALL) .help("equivalent to -vET"), ) .arg( - Arg::with_name(options::NUMBER_NONBLANK) - .short("b") + Arg::new(options::NUMBER_NONBLANK) + .short('b') .long(options::NUMBER_NONBLANK) .help("number nonempty output lines, overrides -n") .overrides_with(options::NUMBER), ) .arg( - Arg::with_name(options::SHOW_NONPRINTING_ENDS) - .short("e") + Arg::new(options::SHOW_NONPRINTING_ENDS) + .short('e') .help("equivalent to -vE"), ) .arg( - Arg::with_name(options::SHOW_ENDS) - .short("E") + Arg::new(options::SHOW_ENDS) + .short('E') .long(options::SHOW_ENDS) .help("display $ at end of each line"), ) .arg( - Arg::with_name(options::NUMBER) - .short("n") + Arg::new(options::NUMBER) + .short('n') .long(options::NUMBER) .help("number all output lines"), ) .arg( - Arg::with_name(options::SQUEEZE_BLANK) - .short("s") + Arg::new(options::SQUEEZE_BLANK) + .short('s') .long(options::SQUEEZE_BLANK) .help("suppress repeated empty output lines"), ) .arg( - Arg::with_name(options::SHOW_NONPRINTING_TABS) - .short("t") + Arg::new(options::SHOW_NONPRINTING_TABS) + .short('t') .long(options::SHOW_NONPRINTING_TABS) .help("equivalent to -vT"), ) .arg( - Arg::with_name(options::SHOW_TABS) - .short("T") + Arg::new(options::SHOW_TABS) + .short('T') .long(options::SHOW_TABS) .help("display TAB characters at ^I"), ) .arg( - Arg::with_name(options::SHOW_NONPRINTING) - .short("v") + Arg::new(options::SHOW_NONPRINTING) + .short('v') .long(options::SHOW_NONPRINTING) .help("use ^ and M- notation, except for LF (\\n) and TAB (\\t)"), ) diff --git a/src/uu/chcon/Cargo.toml b/src/uu/chcon/Cargo.toml index bd30d68fa..01f075476 100644 --- a/src/uu/chcon/Cargo.toml +++ b/src/uu/chcon/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_chcon" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "chcon ~ (uutils) change file security context" @@ -14,7 +14,7 @@ edition = "2018" path = "src/chcon.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version = ">=0.0.9", package="uucore", path="../../uucore", features=["entries", "fs", "perms"] } uucore_procs = { version = ">=0.0.6", package="uucore_procs", path="../../uucore_procs" } selinux = { version = "0.2" } diff --git a/src/uu/chcon/src/chcon.rs b/src/uu/chcon/src/chcon.rs index 32fa23ef8..59da8b68f 100644 --- a/src/uu/chcon/src/chcon.rs +++ b/src/uu/chcon/src/chcon.rs @@ -65,14 +65,14 @@ fn get_usage() -> String { pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = get_usage(); - let config = uu_app().usage(usage.as_ref()); + let config = uu_app().override_usage(usage.as_ref()); let options = match parse_command_line(config, args) { Ok(r) => r, Err(r) => { if let Error::CommandLine(r) = &r { match r.kind { - clap::ErrorKind::HelpDisplayed | clap::ErrorKind::VersionDisplayed => { + clap::ErrorKind::DisplayHelp | clap::ErrorKind::DisplayVersion => { println!("{}", r); return Ok(()); } @@ -160,12 +160,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Err(libc::EXIT_FAILURE.into()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(VERSION) .about(ABOUT) .arg( - Arg::with_name(options::dereference::DEREFERENCE) + Arg::new(options::dereference::DEREFERENCE) .long(options::dereference::DEREFERENCE) .conflicts_with(options::dereference::NO_DEREFERENCE) .help( @@ -174,24 +174,24 @@ pub fn uu_app() -> App<'static, 'static> { ), ) .arg( - Arg::with_name(options::dereference::NO_DEREFERENCE) - .short("h") + Arg::new(options::dereference::NO_DEREFERENCE) + .short('h') .long(options::dereference::NO_DEREFERENCE) .help("Affect symbolic links instead of any referenced file."), ) .arg( - Arg::with_name(options::preserve_root::PRESERVE_ROOT) + Arg::new(options::preserve_root::PRESERVE_ROOT) .long(options::preserve_root::PRESERVE_ROOT) .conflicts_with(options::preserve_root::NO_PRESERVE_ROOT) .help("Fail to operate recursively on '/'."), ) .arg( - Arg::with_name(options::preserve_root::NO_PRESERVE_ROOT) + Arg::new(options::preserve_root::NO_PRESERVE_ROOT) .long(options::preserve_root::NO_PRESERVE_ROOT) .help("Do not treat '/' specially (the default)."), ) .arg( - Arg::with_name(options::REFERENCE) + Arg::new(options::REFERENCE) .long(options::REFERENCE) .takes_value(true) .value_name("RFILE") @@ -199,49 +199,54 @@ pub fn uu_app() -> App<'static, 'static> { .help( "Use security context of RFILE, rather than specifying \ a CONTEXT value.", - ), + ) + .allow_invalid_utf8(true), ) .arg( - Arg::with_name(options::USER) - .short("u") + Arg::new(options::USER) + .short('u') .long(options::USER) .takes_value(true) .value_name("USER") - .help("Set user USER in the target security context."), + .help("Set user USER in the target security context.") + .allow_invalid_utf8(true), ) .arg( - Arg::with_name(options::ROLE) - .short("r") + Arg::new(options::ROLE) + .short('r') .long(options::ROLE) .takes_value(true) .value_name("ROLE") - .help("Set role ROLE in the target security context."), + .help("Set role ROLE in the target security context.") + .allow_invalid_utf8(true), ) .arg( - Arg::with_name(options::TYPE) - .short("t") + Arg::new(options::TYPE) + .short('t') .long(options::TYPE) .takes_value(true) .value_name("TYPE") - .help("Set type TYPE in the target security context."), + .help("Set type TYPE in the target security context.") + .allow_invalid_utf8(true), ) .arg( - Arg::with_name(options::RANGE) - .short("l") + Arg::new(options::RANGE) + .short('l') .long(options::RANGE) .takes_value(true) .value_name("RANGE") - .help("Set range RANGE in the target security context."), + .help("Set range RANGE in the target security context.") + .allow_invalid_utf8(true), ) .arg( - Arg::with_name(options::RECURSIVE) - .short("R") + Arg::new(options::RECURSIVE) + .short('R') .long(options::RECURSIVE) .help("Operate on files and directories recursively."), ) .arg( - Arg::with_name(options::sym_links::FOLLOW_ARG_DIR_SYM_LINK) - .short("H") + Arg::new(options::sym_links::FOLLOW_ARG_DIR_SYM_LINK) + .short('H') .requires(options::RECURSIVE) .overrides_with_all(&[ options::sym_links::FOLLOW_DIR_SYM_LINKS, @@ -253,8 +258,8 @@ pub fn uu_app() -> App<'static, 'static> { ), ) .arg( - Arg::with_name(options::sym_links::FOLLOW_DIR_SYM_LINKS) - .short("L") + Arg::new(options::sym_links::FOLLOW_DIR_SYM_LINKS) + .short('L') .requires(options::RECURSIVE) .overrides_with_all(&[ options::sym_links::FOLLOW_ARG_DIR_SYM_LINK, @@ -266,8 +271,8 @@ pub fn uu_app() -> App<'static, 'static> { ), ) .arg( - Arg::with_name(options::sym_links::NO_FOLLOW_SYM_LINKS) - .short("P") + Arg::new(options::sym_links::NO_FOLLOW_SYM_LINKS) + .short('P') .requires(options::RECURSIVE) .overrides_with_all(&[ options::sym_links::FOLLOW_ARG_DIR_SYM_LINK, @@ -279,12 +284,17 @@ pub fn uu_app() -> App<'static, 'static> { ), ) .arg( - Arg::with_name(options::VERBOSE) - .short("v") + Arg::new(options::VERBOSE) + .short('v') .long(options::VERBOSE) .help("Output a diagnostic for every file processed."), ) - .arg(Arg::with_name("FILE").multiple(true).min_values(1)) + .arg( + Arg::new("FILE") + .multiple_occurrences(true) + .min_values(1) + .allow_invalid_utf8(true), + ) } #[derive(Debug)] @@ -298,7 +308,7 @@ struct Options { } fn parse_command_line(config: clap::App, args: impl uucore::Args) -> Result { - let matches = config.get_matches_from_safe(args)?; + let matches = config.try_get_matches_from(args)?; let verbose = matches.is_present(options::VERBOSE); diff --git a/src/uu/chgrp/Cargo.toml b/src/uu/chgrp/Cargo.toml index 67b9c12f9..b2bd6ef0f 100644 --- a/src/uu/chgrp/Cargo.toml +++ b/src/uu/chgrp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_chgrp" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "chgrp ~ (uutils) change the group ownership of FILE" @@ -15,7 +15,7 @@ edition = "2018" path = "src/chgrp.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "fs", "perms"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/chgrp/src/chgrp.rs b/src/uu/chgrp/src/chgrp.rs index c70e5e5c7..ad0b46755 100644 --- a/src/uu/chgrp/src/chgrp.rs +++ b/src/uu/chgrp/src/chgrp.rs @@ -56,7 +56,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = get_usage(); chown_base( - uu_app().usage(&usage[..]), + uu_app().override_usage(&usage[..]), args, options::ARG_GROUP, parse_gid_and_uid, @@ -64,82 +64,82 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { ) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(VERSION) .about(ABOUT) .arg( - Arg::with_name(options::verbosity::CHANGES) - .short("c") + Arg::new(options::verbosity::CHANGES) + .short('c') .long(options::verbosity::CHANGES) .help("like verbose but report only when a change is made"), ) .arg( - Arg::with_name(options::verbosity::SILENT) - .short("f") + Arg::new(options::verbosity::SILENT) + .short('f') .long(options::verbosity::SILENT), ) .arg( - Arg::with_name(options::verbosity::QUIET) + Arg::new(options::verbosity::QUIET) .long(options::verbosity::QUIET) .help("suppress most error messages"), ) .arg( - Arg::with_name(options::verbosity::VERBOSE) - .short("v") + Arg::new(options::verbosity::VERBOSE) + .short('v') .long(options::verbosity::VERBOSE) .help("output a diagnostic for every file processed"), ) .arg( - Arg::with_name(options::dereference::DEREFERENCE) + Arg::new(options::dereference::DEREFERENCE) .long(options::dereference::DEREFERENCE), ) .arg( - Arg::with_name(options::dereference::NO_DEREFERENCE) - .short("h") + Arg::new(options::dereference::NO_DEREFERENCE) + .short('h') .long(options::dereference::NO_DEREFERENCE) .help( "affect symbolic links instead of any referenced file (useful only on systems that can change the ownership of a symlink)", ), ) .arg( - Arg::with_name(options::preserve_root::PRESERVE) + Arg::new(options::preserve_root::PRESERVE) .long(options::preserve_root::PRESERVE) .help("fail to operate recursively on '/'"), ) .arg( - Arg::with_name(options::preserve_root::NO_PRESERVE) + Arg::new(options::preserve_root::NO_PRESERVE) .long(options::preserve_root::NO_PRESERVE) .help("do not treat '/' specially (the default)"), ) .arg( - Arg::with_name(options::REFERENCE) + Arg::new(options::REFERENCE) .long(options::REFERENCE) .value_name("RFILE") .help("use RFILE's group rather than specifying GROUP values") .takes_value(true) - .multiple(false), + .multiple_occurrences(false), ) .arg( - Arg::with_name(options::RECURSIVE) - .short("R") + Arg::new(options::RECURSIVE) + .short('R') .long(options::RECURSIVE) .help("operate on files and directories recursively"), ) .arg( - Arg::with_name(options::traverse::TRAVERSE) - .short(options::traverse::TRAVERSE) + Arg::new(options::traverse::TRAVERSE) + .short(options::traverse::TRAVERSE.chars().next().unwrap()) .help("if a command line argument is a symbolic link to a directory, traverse it"), ) .arg( - Arg::with_name(options::traverse::NO_TRAVERSE) - .short(options::traverse::NO_TRAVERSE) + Arg::new(options::traverse::NO_TRAVERSE) + .short(options::traverse::NO_TRAVERSE.chars().next().unwrap()) .help("do not traverse any symbolic links (default)") .overrides_with_all(&[options::traverse::TRAVERSE, options::traverse::EVERY]), ) .arg( - Arg::with_name(options::traverse::EVERY) - .short(options::traverse::EVERY) + Arg::new(options::traverse::EVERY) + .short(options::traverse::EVERY.chars().next().unwrap()) .help("traverse every symbolic link to a directory encountered"), ) } diff --git a/src/uu/chmod/Cargo.toml b/src/uu/chmod/Cargo.toml index eb05fb752..c51d3e25f 100644 --- a/src/uu/chmod/Cargo.toml +++ b/src/uu/chmod/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_chmod" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "chmod ~ (uutils) change mode of FILE" @@ -15,7 +15,7 @@ edition = "2018" path = "src/chmod.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs", "mode"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/chmod/src/chmod.rs b/src/uu/chmod/src/chmod.rs index 09ed3cda6..622311ee4 100644 --- a/src/uu/chmod/src/chmod.rs +++ b/src/uu/chmod/src/chmod.rs @@ -62,7 +62,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let after_help = get_long_usage(); let matches = uu_app() - .usage(&usage[..]) + .override_usage(&usage[..]) .after_help(&after_help[..]) .get_matches_from(args); @@ -121,63 +121,63 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { chmoder.chmod(files) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(options::CHANGES) + Arg::new(options::CHANGES) .long(options::CHANGES) - .short("c") + .short('c') .help("like verbose but report only when a change is made"), ) .arg( - Arg::with_name(options::QUIET) + Arg::new(options::QUIET) .long(options::QUIET) .visible_alias("silent") - .short("f") + .short('f') .help("suppress most error messages"), ) .arg( - Arg::with_name(options::VERBOSE) + Arg::new(options::VERBOSE) .long(options::VERBOSE) - .short("v") + .short('v') .help("output a diagnostic for every file processed"), ) .arg( - Arg::with_name(options::NO_PRESERVE_ROOT) + Arg::new(options::NO_PRESERVE_ROOT) .long(options::NO_PRESERVE_ROOT) .help("do not treat '/' specially (the default)"), ) .arg( - Arg::with_name(options::PRESERVE_ROOT) + Arg::new(options::PRESERVE_ROOT) .long(options::PRESERVE_ROOT) .help("fail to operate recursively on '/'"), ) .arg( - Arg::with_name(options::RECURSIVE) + Arg::new(options::RECURSIVE) .long(options::RECURSIVE) - .short("R") + .short('R') .help("change files and directories recursively"), ) .arg( - Arg::with_name(options::REFERENCE) + Arg::new(options::REFERENCE) .long("reference") .takes_value(true) .help("use RFILE's mode instead of MODE values"), ) .arg( - Arg::with_name(options::MODE) - .required_unless(options::REFERENCE) + Arg::new(options::MODE) + .required_unless_present(options::REFERENCE) .takes_value(true), // It would be nice if clap could parse with delimiter, e.g. "g-x,u+x", - // however .multiple(true) cannot be used here because FILE already needs that. - // Only one positional argument with .multiple(true) set is allowed per command + // however .multiple_occurrences(true) cannot be used here because FILE already needs that. + // Only one positional argument with .multiple_occurrences(true) set is allowed per command ) .arg( - Arg::with_name(options::FILE) - .required_unless(options::MODE) - .multiple(true), + Arg::new(options::FILE) + .required_unless_present(options::MODE) + .multiple_occurrences(true), ) } diff --git a/src/uu/chown/Cargo.toml b/src/uu/chown/Cargo.toml index 50bd7bc18..1b3cddb0a 100644 --- a/src/uu/chown/Cargo.toml +++ b/src/uu/chown/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_chown" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "chown ~ (uutils) change the ownership of FILE" @@ -15,7 +15,7 @@ edition = "2018" path = "src/chown.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "fs", "perms"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/chown/src/chown.rs b/src/uu/chown/src/chown.rs index 7b0c94810..940b99072 100644 --- a/src/uu/chown/src/chown.rs +++ b/src/uu/chown/src/chown.rs @@ -59,7 +59,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = get_usage(); chown_base( - uu_app().usage(&usage[..]), + uu_app().override_usage(&usage[..]), args, options::ARG_OWNER, parse_gid_uid_and_filter, @@ -67,18 +67,18 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { ) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(options::verbosity::CHANGES) - .short("c") + Arg::new(options::verbosity::CHANGES) + .short('c') .long(options::verbosity::CHANGES) .help("like verbose but report only when a change is made"), ) .arg( - Arg::with_name(options::dereference::DEREFERENCE) + Arg::new(options::dereference::DEREFERENCE) .long(options::dereference::DEREFERENCE) .help( "affect the referent of each symbolic link (this is the default), \ @@ -86,8 +86,8 @@ pub fn uu_app() -> App<'static, 'static> { ), ) .arg( - Arg::with_name(options::dereference::NO_DEREFERENCE) - .short("h") + Arg::new(options::dereference::NO_DEREFERENCE) + .short('h') .long(options::dereference::NO_DEREFERENCE) .help( "affect symbolic links instead of any referenced file \ @@ -95,7 +95,7 @@ pub fn uu_app() -> App<'static, 'static> { ), ) .arg( - Arg::with_name(options::FROM) + Arg::new(options::FROM) .long(options::FROM) .help( "change the owner and/or group of each file only if its \ @@ -106,60 +106,60 @@ pub fn uu_app() -> App<'static, 'static> { .value_name("CURRENT_OWNER:CURRENT_GROUP"), ) .arg( - Arg::with_name(options::preserve_root::PRESERVE) + Arg::new(options::preserve_root::PRESERVE) .long(options::preserve_root::PRESERVE) .help("fail to operate recursively on '/'"), ) .arg( - Arg::with_name(options::preserve_root::NO_PRESERVE) + Arg::new(options::preserve_root::NO_PRESERVE) .long(options::preserve_root::NO_PRESERVE) .help("do not treat '/' specially (the default)"), ) .arg( - Arg::with_name(options::verbosity::QUIET) + Arg::new(options::verbosity::QUIET) .long(options::verbosity::QUIET) .help("suppress most error messages"), ) .arg( - Arg::with_name(options::RECURSIVE) - .short("R") + Arg::new(options::RECURSIVE) + .short('R') .long(options::RECURSIVE) .help("operate on files and directories recursively"), ) .arg( - Arg::with_name(options::REFERENCE) + Arg::new(options::REFERENCE) .long(options::REFERENCE) .help("use RFILE's owner and group rather than specifying OWNER:GROUP values") .value_name("RFILE") .min_values(1), ) .arg( - Arg::with_name(options::verbosity::SILENT) - .short("f") + Arg::new(options::verbosity::SILENT) + .short('f') .long(options::verbosity::SILENT), ) .arg( - Arg::with_name(options::traverse::TRAVERSE) - .short(options::traverse::TRAVERSE) + Arg::new(options::traverse::TRAVERSE) + .short(options::traverse::TRAVERSE.chars().next().unwrap()) .help("if a command line argument is a symbolic link to a directory, traverse it") .overrides_with_all(&[options::traverse::EVERY, options::traverse::NO_TRAVERSE]), ) .arg( - Arg::with_name(options::traverse::EVERY) - .short(options::traverse::EVERY) + Arg::new(options::traverse::EVERY) + .short(options::traverse::EVERY.chars().next().unwrap()) .help("traverse every symbolic link to a directory encountered") .overrides_with_all(&[options::traverse::TRAVERSE, options::traverse::NO_TRAVERSE]), ) .arg( - Arg::with_name(options::traverse::NO_TRAVERSE) - .short(options::traverse::NO_TRAVERSE) + Arg::new(options::traverse::NO_TRAVERSE) + .short(options::traverse::NO_TRAVERSE.chars().next().unwrap()) .help("do not traverse any symbolic links (default)") .overrides_with_all(&[options::traverse::TRAVERSE, options::traverse::EVERY]), ) .arg( - Arg::with_name(options::verbosity::VERBOSE) + Arg::new(options::verbosity::VERBOSE) .long(options::verbosity::VERBOSE) - .short("v") + .short('v') .help("output a diagnostic for every file processed"), ) } diff --git a/src/uu/chroot/Cargo.toml b/src/uu/chroot/Cargo.toml index 2dd23af68..31fdc431c 100644 --- a/src/uu/chroot/Cargo.toml +++ b/src/uu/chroot/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_chroot" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "chroot ~ (uutils) run COMMAND under a new root directory" @@ -15,7 +15,7 @@ edition = "2018" path = "src/chroot.rs" [dependencies] -clap= "2.33" +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/chroot/src/chroot.rs b/src/uu/chroot/src/chroot.rs index 66105b620..7a57c3c4c 100644 --- a/src/uu/chroot/src/chroot.rs +++ b/src/uu/chroot/src/chroot.rs @@ -91,40 +91,40 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) - .usage(SYNTAX) + .override_usage(SYNTAX) .arg( - Arg::with_name(options::NEWROOT) - .hidden(true) + Arg::new(options::NEWROOT) + .hide(true) .required(true) .index(1), ) .arg( - Arg::with_name(options::USER) - .short("u") + Arg::new(options::USER) + .short('u') .long(options::USER) .help("User (ID or name) to switch before running the program") .value_name("USER"), ) .arg( - Arg::with_name(options::GROUP) - .short("g") + Arg::new(options::GROUP) + .short('g') .long(options::GROUP) .help("Group (ID or name) to switch to") .value_name("GROUP"), ) .arg( - Arg::with_name(options::GROUPS) - .short("G") + Arg::new(options::GROUPS) + .short('G') .long(options::GROUPS) .help("Comma-separated list of groups to switch to") .value_name("GROUP1,GROUP2..."), ) .arg( - Arg::with_name(options::USERSPEC) + Arg::new(options::USERSPEC) .long(options::USERSPEC) .help( "Colon-separated user and group to switch to. \ @@ -134,9 +134,9 @@ pub fn uu_app() -> App<'static, 'static> { .value_name("USER:GROUP"), ) .arg( - Arg::with_name(options::COMMAND) - .hidden(true) - .multiple(true) + Arg::new(options::COMMAND) + .hide(true) + .multiple_occurrences(true) .index(2), ) } diff --git a/src/uu/cksum/Cargo.toml b/src/uu/cksum/Cargo.toml index bc06d5340..c22615d01 100644 --- a/src/uu/cksum/Cargo.toml +++ b/src/uu/cksum/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_cksum" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "cksum ~ (uutils) display CRC and size of input" @@ -15,7 +15,7 @@ edition = "2018" path = "src/cksum.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/cksum/src/cksum.rs b/src/uu/cksum/src/cksum.rs index ca87da2a8..3fe7f9437 100644 --- a/src/uu/cksum/src/cksum.rs +++ b/src/uu/cksum/src/cksum.rs @@ -140,11 +140,15 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .name(NAME) .version(crate_version!()) .about(SUMMARY) - .usage(SYNTAX) - .arg(Arg::with_name(options::FILE).hidden(true).multiple(true)) + .override_usage(SYNTAX) + .arg( + Arg::new(options::FILE) + .hide(true) + .multiple_occurrences(true), + ) } diff --git a/src/uu/comm/Cargo.toml b/src/uu/comm/Cargo.toml index afc8afde1..2a4f1ef04 100644 --- a/src/uu/comm/Cargo.toml +++ b/src/uu/comm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_comm" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "comm ~ (uutils) compare sorted inputs" @@ -15,7 +15,7 @@ edition = "2018" path = "src/comm.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/comm/src/comm.rs b/src/uu/comm/src/comm.rs index 2f800da8a..f7399db51 100644 --- a/src/uu/comm/src/comm.rs +++ b/src/uu/comm/src/comm.rs @@ -137,7 +137,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { .collect_str(InvalidEncodingHandling::ConvertLossy) .accept_any(); - let matches = uu_app().usage(&usage[..]).get_matches_from(args); + let matches = uu_app().override_usage(&usage[..]).get_matches_from(args); let filename1 = matches.value_of(options::FILE_1).unwrap(); let filename2 = matches.value_of(options::FILE_2).unwrap(); let mut f1 = open_file(filename1).map_err_context(|| filename1.to_string())?; @@ -147,34 +147,34 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .after_help(LONG_HELP) .arg( - Arg::with_name(options::COLUMN_1) - .short(options::COLUMN_1) + Arg::new(options::COLUMN_1) + .short('1') .help("suppress column 1 (lines unique to FILE1)"), ) .arg( - Arg::with_name(options::COLUMN_2) - .short(options::COLUMN_2) + Arg::new(options::COLUMN_2) + .short('2') .help("suppress column 2 (lines unique to FILE2)"), ) .arg( - Arg::with_name(options::COLUMN_3) - .short(options::COLUMN_3) + Arg::new(options::COLUMN_3) + .short('3') .help("suppress column 3 (lines that appear in both files)"), ) .arg( - Arg::with_name(options::DELIMITER) + Arg::new(options::DELIMITER) .long(options::DELIMITER) .help("separate columns with STR") .value_name("STR") .default_value(options::DELIMITER_DEFAULT) .hide_default_value(true), ) - .arg(Arg::with_name(options::FILE_1).required(true)) - .arg(Arg::with_name(options::FILE_2).required(true)) + .arg(Arg::new(options::FILE_1).required(true)) + .arg(Arg::new(options::FILE_2).required(true)) } diff --git a/src/uu/cp/Cargo.toml b/src/uu/cp/Cargo.toml index 5fcd70acb..bce056c94 100644 --- a/src/uu/cp/Cargo.toml +++ b/src/uu/cp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_cp" -version = "0.0.9" +version = "0.0.12" authors = [ "Jordy Dickinson ", "Joshua S. Miller ", @@ -19,7 +19,7 @@ edition = "2018" path = "src/cp.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } filetime = "0.2" libc = "0.2.85" quick-error = "1.2.3" diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 4f4f10186..aa6da3f94 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -296,65 +296,65 @@ static DEFAULT_ATTRIBUTES: &[Attribute] = &[ Attribute::Timestamps, ]; -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) - .arg(Arg::with_name(options::TARGET_DIRECTORY) - .short("t") + .arg(Arg::new(options::TARGET_DIRECTORY) + .short('t') .conflicts_with(options::NO_TARGET_DIRECTORY) .long(options::TARGET_DIRECTORY) .value_name(options::TARGET_DIRECTORY) .takes_value(true) .help("copy all SOURCE arguments into target-directory")) - .arg(Arg::with_name(options::NO_TARGET_DIRECTORY) - .short("T") + .arg(Arg::new(options::NO_TARGET_DIRECTORY) + .short('T') .long(options::NO_TARGET_DIRECTORY) .conflicts_with(options::TARGET_DIRECTORY) .help("Treat DEST as a regular file and not a directory")) - .arg(Arg::with_name(options::INTERACTIVE) - .short("i") + .arg(Arg::new(options::INTERACTIVE) + .short('i') .long(options::INTERACTIVE) .conflicts_with(options::NO_CLOBBER) .help("ask before overwriting files")) - .arg(Arg::with_name(options::LINK) - .short("l") + .arg(Arg::new(options::LINK) + .short('l') .long(options::LINK) .overrides_with(options::REFLINK) .help("hard-link files instead of copying")) - .arg(Arg::with_name(options::NO_CLOBBER) - .short("n") + .arg(Arg::new(options::NO_CLOBBER) + .short('n') .long(options::NO_CLOBBER) .conflicts_with(options::INTERACTIVE) .help("don't overwrite a file that already exists")) - .arg(Arg::with_name(options::RECURSIVE) - .short("r") + .arg(Arg::new(options::RECURSIVE) + .short('r') .long(options::RECURSIVE) // --archive sets this option .help("copy directories recursively")) - .arg(Arg::with_name(options::RECURSIVE_ALIAS) - .short("R") + .arg(Arg::new(options::RECURSIVE_ALIAS) + .short('R') .help("same as -r")) - .arg(Arg::with_name(options::STRIP_TRAILING_SLASHES) + .arg(Arg::new(options::STRIP_TRAILING_SLASHES) .long(options::STRIP_TRAILING_SLASHES) .help("remove any trailing slashes from each SOURCE argument")) - .arg(Arg::with_name(options::VERBOSE) - .short("v") + .arg(Arg::new(options::VERBOSE) + .short('v') .long(options::VERBOSE) .help("explicitly state what is being done")) - .arg(Arg::with_name(options::SYMBOLIC_LINK) - .short("s") + .arg(Arg::new(options::SYMBOLIC_LINK) + .short('s') .long(options::SYMBOLIC_LINK) .conflicts_with(options::LINK) .overrides_with(options::REFLINK) .help("make symbolic links instead of copying")) - .arg(Arg::with_name(options::FORCE) - .short("f") + .arg(Arg::new(options::FORCE) + .short('f') .long(options::FORCE) .help("if an existing destination file cannot be opened, remove it and \ try again (this option is ignored when the -n option is also used). \ Currently not implemented for Windows.")) - .arg(Arg::with_name(options::REMOVE_DESTINATION) + .arg(Arg::new(options::REMOVE_DESTINATION) .long(options::REMOVE_DESTINATION) .conflicts_with(options::FORCE) .help("remove each existing destination file before attempting to open it \ @@ -362,25 +362,25 @@ pub fn uu_app() -> App<'static, 'static> { .arg(backup_control::arguments::backup()) .arg(backup_control::arguments::backup_no_args()) .arg(backup_control::arguments::suffix()) - .arg(Arg::with_name(options::UPDATE) - .short("u") + .arg(Arg::new(options::UPDATE) + .short('u') .long(options::UPDATE) .help("copy only when the SOURCE file is newer than the destination file \ or when the destination file is missing")) - .arg(Arg::with_name(options::REFLINK) + .arg(Arg::new(options::REFLINK) .long(options::REFLINK) .takes_value(true) .value_name("WHEN") .help("control clone/CoW copies. See below")) - .arg(Arg::with_name(options::ATTRIBUTES_ONLY) + .arg(Arg::new(options::ATTRIBUTES_ONLY) .long(options::ATTRIBUTES_ONLY) .conflicts_with(options::COPY_CONTENTS) .overrides_with(options::REFLINK) .help("Don't copy the file data, just the attributes")) - .arg(Arg::with_name(options::PRESERVE) + .arg(Arg::new(options::PRESERVE) .long(options::PRESERVE) .takes_value(true) - .multiple(true) + .multiple_occurrences(true) .use_delimiter(true) .possible_values(PRESERVABLE_ATTRIBUTES) .min_values(0) @@ -390,67 +390,67 @@ pub fn uu_app() -> App<'static, 'static> { // --archive sets this option .help("Preserve the specified attributes (default: mode, ownership (unix only), timestamps), \ if possible additional attributes: context, links, xattr, all")) - .arg(Arg::with_name(options::PRESERVE_DEFAULT_ATTRIBUTES) - .short("-p") + .arg(Arg::new(options::PRESERVE_DEFAULT_ATTRIBUTES) + .short('p') .long(options::PRESERVE_DEFAULT_ATTRIBUTES) .conflicts_with_all(&[options::PRESERVE, options::NO_PRESERVE, options::ARCHIVE]) .help("same as --preserve=mode,ownership(unix only),timestamps")) - .arg(Arg::with_name(options::NO_PRESERVE) + .arg(Arg::new(options::NO_PRESERVE) .long(options::NO_PRESERVE) .takes_value(true) .value_name("ATTR_LIST") .conflicts_with_all(&[options::PRESERVE_DEFAULT_ATTRIBUTES, options::PRESERVE, options::ARCHIVE]) .help("don't preserve the specified attributes")) - .arg(Arg::with_name(options::PARENTS) + .arg(Arg::new(options::PARENTS) .long(options::PARENTS) .alias(options::PARENT) .help("use full source file name under DIRECTORY")) - .arg(Arg::with_name(options::NO_DEREFERENCE) - .short("-P") + .arg(Arg::new(options::NO_DEREFERENCE) + .short('P') .long(options::NO_DEREFERENCE) .conflicts_with(options::DEREFERENCE) // -d sets this option .help("never follow symbolic links in SOURCE")) - .arg(Arg::with_name(options::DEREFERENCE) - .short("L") + .arg(Arg::new(options::DEREFERENCE) + .short('L') .long(options::DEREFERENCE) .conflicts_with(options::NO_DEREFERENCE) .help("always follow symbolic links in SOURCE")) - .arg(Arg::with_name(options::ARCHIVE) - .short("a") + .arg(Arg::new(options::ARCHIVE) + .short('a') .long(options::ARCHIVE) .conflicts_with_all(&[options::PRESERVE_DEFAULT_ATTRIBUTES, options::PRESERVE, options::NO_PRESERVE]) .help("Same as -dR --preserve=all")) - .arg(Arg::with_name(options::NO_DEREFERENCE_PRESERVE_LINKS) - .short("d") + .arg(Arg::new(options::NO_DEREFERENCE_PRESERVE_LINKS) + .short('d') .help("same as --no-dereference --preserve=links")) - .arg(Arg::with_name(options::ONE_FILE_SYSTEM) - .short("x") + .arg(Arg::new(options::ONE_FILE_SYSTEM) + .short('x') .long(options::ONE_FILE_SYSTEM) .help("stay on this file system")) // TODO: implement the following args - .arg(Arg::with_name(options::COPY_CONTENTS) + .arg(Arg::new(options::COPY_CONTENTS) .long(options::COPY_CONTENTS) .conflicts_with(options::ATTRIBUTES_ONLY) .help("NotImplemented: copy contents of special files when recursive")) - .arg(Arg::with_name(options::SPARSE) + .arg(Arg::new(options::SPARSE) .long(options::SPARSE) .takes_value(true) .value_name("WHEN") .help("NotImplemented: control creation of sparse files. See below")) - .arg(Arg::with_name(options::CONTEXT) + .arg(Arg::new(options::CONTEXT) .long(options::CONTEXT) .takes_value(true) .value_name("CTX") .help("NotImplemented: set SELinux security context of destination file to default type")) - .arg(Arg::with_name(options::CLI_SYMBOLIC_LINKS) - .short("H") + .arg(Arg::new(options::CLI_SYMBOLIC_LINKS) + .short('H') .help("NotImplemented: follow command-line symbolic links in SOURCE")) // END TODO - .arg(Arg::with_name(options::PATHS) - .multiple(true)) + .arg(Arg::new(options::PATHS) + .multiple_occurrences(true)) } #[uucore_procs::gen_uumain] @@ -462,7 +462,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { LONG_HELP, backup_control::BACKUP_CONTROL_LONG_HELP )) - .usage(&usage[..]) + .override_usage(&usage[..]) .get_matches_from(args); let options = Options::from_matches(&matches)?; diff --git a/src/uu/csplit/Cargo.toml b/src/uu/csplit/Cargo.toml index e8b479772..881f9fa55 100644 --- a/src/uu/csplit/Cargo.toml +++ b/src/uu/csplit/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_csplit" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "csplit ~ (uutils) Output pieces of FILE separated by PATTERN(s) to files 'xx00', 'xx01', ..., and output byte counts of each piece to standard output" @@ -15,7 +15,7 @@ edition = "2018" path = "src/csplit.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } thiserror = "1.0" regex = "1.0.0" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "fs"] } diff --git a/src/uu/csplit/src/csplit.rs b/src/uu/csplit/src/csplit.rs index b4bf72d96..f109f0cdf 100644 --- a/src/uu/csplit/src/csplit.rs +++ b/src/uu/csplit/src/csplit.rs @@ -722,7 +722,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { .collect_str(InvalidEncodingHandling::Ignore) .accept_any(); - let matches = uu_app().usage(&usage[..]).get_matches_from(args); + let matches = uu_app().override_usage(&usage[..]).get_matches_from(args); // get the file to split let file_name = matches.value_of(options::FILE).unwrap(); @@ -751,60 +751,60 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(SUMMARY) .arg( - Arg::with_name(options::SUFFIX_FORMAT) - .short("b") + Arg::new(options::SUFFIX_FORMAT) + .short('b') .long(options::SUFFIX_FORMAT) .value_name("FORMAT") .help("use sprintf FORMAT instead of %02d"), ) .arg( - Arg::with_name(options::PREFIX) - .short("f") + Arg::new(options::PREFIX) + .short('f') .long(options::PREFIX) .value_name("PREFIX") .help("use PREFIX instead of 'xx'"), ) .arg( - Arg::with_name(options::KEEP_FILES) - .short("k") + Arg::new(options::KEEP_FILES) + .short('k') .long(options::KEEP_FILES) .help("do not remove output files on errors"), ) .arg( - Arg::with_name(options::SUPPRESS_MATCHED) + Arg::new(options::SUPPRESS_MATCHED) .long(options::SUPPRESS_MATCHED) .help("suppress the lines matching PATTERN"), ) .arg( - Arg::with_name(options::DIGITS) - .short("n") + Arg::new(options::DIGITS) + .short('n') .long(options::DIGITS) .value_name("DIGITS") .help("use specified number of digits instead of 2"), ) .arg( - Arg::with_name(options::QUIET) - .short("s") + Arg::new(options::QUIET) + .short('s') .long(options::QUIET) .visible_alias("silent") .help("do not print counts of output file sizes"), ) .arg( - Arg::with_name(options::ELIDE_EMPTY_FILES) - .short("z") + Arg::new(options::ELIDE_EMPTY_FILES) + .short('z') .long(options::ELIDE_EMPTY_FILES) .help("remove empty output files"), ) - .arg(Arg::with_name(options::FILE).hidden(true).required(true)) + .arg(Arg::new(options::FILE).hide(true).required(true)) .arg( - Arg::with_name(options::PATTERN) - .hidden(true) - .multiple(true) + Arg::new(options::PATTERN) + .hide(true) + .multiple_occurrences(true) .required(true), ) .after_help(LONG_HELP) diff --git a/src/uu/cut/Cargo.toml b/src/uu/cut/Cargo.toml index 331a00dcc..9d25c5574 100644 --- a/src/uu/cut/Cargo.toml +++ b/src/uu/cut/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_cut" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "cut ~ (uutils) display byte/field columns of input lines" @@ -15,7 +15,7 @@ edition = "2018" path = "src/cut.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } memchr = "2" diff --git a/src/uu/cut/src/cut.rs b/src/uu/cut/src/cut.rs index 8dfdf25f8..08e6c396d 100644 --- a/src/uu/cut/src/cut.rs +++ b/src/uu/cut/src/cut.rs @@ -532,16 +532,16 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .name(NAME) .version(crate_version!()) - .usage(SYNTAX) + .override_usage(SYNTAX) .about(SUMMARY) .after_help(LONG_HELP) .arg( - Arg::with_name(options::BYTES) - .short("b") + Arg::new(options::BYTES) + .short('b') .long(options::BYTES) .takes_value(true) .help("filter byte columns from the input source") @@ -550,8 +550,8 @@ pub fn uu_app() -> App<'static, 'static> { .display_order(1), ) .arg( - Arg::with_name(options::CHARACTERS) - .short("c") + Arg::new(options::CHARACTERS) + .short('c') .long(options::CHARACTERS) .help("alias for character mode") .takes_value(true) @@ -560,8 +560,8 @@ pub fn uu_app() -> App<'static, 'static> { .display_order(2), ) .arg( - Arg::with_name(options::DELIMITER) - .short("d") + Arg::new(options::DELIMITER) + .short('d') .long(options::DELIMITER) .help("specify the delimiter character that separates fields in the input source. Defaults to Tab.") .takes_value(true) @@ -569,8 +569,8 @@ pub fn uu_app() -> App<'static, 'static> { .display_order(3), ) .arg( - Arg::with_name(options::FIELDS) - .short("f") + Arg::new(options::FIELDS) + .short('f') .long(options::FIELDS) .help("filter field columns from the input source") .takes_value(true) @@ -579,30 +579,30 @@ pub fn uu_app() -> App<'static, 'static> { .display_order(4), ) .arg( - Arg::with_name(options::COMPLEMENT) + Arg::new(options::COMPLEMENT) .long(options::COMPLEMENT) .help("invert the filter - instead of displaying only the filtered columns, display all but those columns") .takes_value(false) .display_order(5), ) .arg( - Arg::with_name(options::ONLY_DELIMITED) - .short("s") + Arg::new(options::ONLY_DELIMITED) + .short('s') .long(options::ONLY_DELIMITED) .help("in field mode, only print lines which contain the delimiter") .takes_value(false) .display_order(6), ) .arg( - Arg::with_name(options::ZERO_TERMINATED) - .short("z") + Arg::new(options::ZERO_TERMINATED) + .short('z') .long(options::ZERO_TERMINATED) .help("instead of filtering columns based on line, filter columns based on \\0 (NULL character)") .takes_value(false) .display_order(8), ) .arg( - Arg::with_name(options::OUTPUT_DELIMITER) + Arg::new(options::OUTPUT_DELIMITER) .long(options::OUTPUT_DELIMITER) .help("in field mode, replace the delimiter in output lines with this option's argument") .takes_value(true) @@ -610,8 +610,8 @@ pub fn uu_app() -> App<'static, 'static> { .display_order(7), ) .arg( - Arg::with_name(options::FILE) - .hidden(true) - .multiple(true) + Arg::new(options::FILE) + .hide(true) + .multiple_occurrences(true) ) } diff --git a/src/uu/date/Cargo.toml b/src/uu/date/Cargo.toml index 7e7d033f5..76c35fcd5 100644 --- a/src/uu/date/Cargo.toml +++ b/src/uu/date/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_date" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "date ~ (uutils) display or set the current time" @@ -16,7 +16,7 @@ path = "src/date.rs" [dependencies] chrono = "^0.4.11" -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/date/src/date.rs b/src/uu/date/src/date.rs index bd814353f..8ffd62c0d 100644 --- a/src/uu/date/src/date.rs +++ b/src/uu/date/src/date.rs @@ -147,7 +147,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { {0} [OPTION]... [MMDDhhmm[[CC]YY][.ss]]", NAME ); - let matches = uu_app().usage(&syntax[..]).get_matches_from(args); + let matches = uu_app().override_usage(&syntax[..]).get_matches_from(args); let format = if let Some(form) = matches.value_of(OPT_FORMAT) { if !form.starts_with('+') { @@ -257,70 +257,70 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(OPT_DATE) - .short("d") + Arg::new(OPT_DATE) + .short('d') .long(OPT_DATE) .takes_value(true) .help("display time described by STRING, not 'now'"), ) .arg( - Arg::with_name(OPT_FILE) - .short("f") + Arg::new(OPT_FILE) + .short('f') .long(OPT_FILE) .takes_value(true) .help("like --date; once for each line of DATEFILE"), ) .arg( - Arg::with_name(OPT_ISO_8601) - .short("I") + Arg::new(OPT_ISO_8601) + .short('I') .long(OPT_ISO_8601) .takes_value(true) .help(ISO_8601_HELP_STRING), ) .arg( - Arg::with_name(OPT_RFC_EMAIL) - .short("R") + Arg::new(OPT_RFC_EMAIL) + .short('R') .long(OPT_RFC_EMAIL) .help(RFC_5322_HELP_STRING), ) .arg( - Arg::with_name(OPT_RFC_3339) + Arg::new(OPT_RFC_3339) .long(OPT_RFC_3339) .takes_value(true) .help(RFC_3339_HELP_STRING), ) .arg( - Arg::with_name(OPT_DEBUG) + Arg::new(OPT_DEBUG) .long(OPT_DEBUG) .help("annotate the parsed date, and warn about questionable usage to stderr"), ) .arg( - Arg::with_name(OPT_REFERENCE) - .short("r") + Arg::new(OPT_REFERENCE) + .short('r') .long(OPT_REFERENCE) .takes_value(true) .help("display the last modification time of FILE"), ) .arg( - Arg::with_name(OPT_SET) - .short("s") + Arg::new(OPT_SET) + .short('s') .long(OPT_SET) .takes_value(true) .help(OPT_SET_HELP_STRING), ) .arg( - Arg::with_name(OPT_UNIVERSAL) - .short("u") + Arg::new(OPT_UNIVERSAL) + .short('u') .long(OPT_UNIVERSAL) .alias(OPT_UNIVERSAL_2) .help("print or set Coordinated Universal Time (UTC)"), ) - .arg(Arg::with_name(OPT_FORMAT).multiple(false)) + .arg(Arg::new(OPT_FORMAT).multiple_occurrences(false)) } /// Return the appropriate format string for the given settings. diff --git a/src/uu/dd/Cargo.toml b/src/uu/dd/Cargo.toml index 57052119f..de8fc31d5 100644 --- a/src/uu/dd/Cargo.toml +++ b/src/uu/dd/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_dd" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "dd ~ (uutils) copy and convert files" @@ -16,7 +16,7 @@ path = "src/dd.rs" [dependencies] byte-unit = "4.0" -clap = { version = "2.33", features = [ "wrap_help" ] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } gcd = "2.0" libc = "0.2" uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } diff --git a/src/uu/dd/src/dd.rs b/src/uu/dd/src/dd.rs index 644d7abb0..3e8cd19c4 100644 --- a/src/uu/dd/src/dd.rs +++ b/src/uu/dd/src/dd.rs @@ -36,7 +36,7 @@ use std::thread; use std::time; use byte_unit::Byte; -use clap::{self, crate_version}; +use clap::{crate_version, App, Arg, ArgMatches}; use gcd::Gcd; #[cfg(target_os = "linux")] use signal_hook::consts::signal; @@ -932,12 +932,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app() -> clap::App<'static, 'static> { - clap::App::new(uucore::util_name()) +pub fn uu_app<'a>() -> App<'a> { + App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - clap::Arg::with_name(options::INFILE) + Arg::new(options::INFILE) .long(options::INFILE) .takes_value(true) .require_equals(true) @@ -945,7 +945,7 @@ pub fn uu_app() -> clap::App<'static, 'static> { .help("(alternatively if=FILE) specifies the file used for input. When not specified, stdin is used instead") ) .arg( - clap::Arg::with_name(options::OUTFILE) + Arg::new(options::OUTFILE) .long(options::OUTFILE) .takes_value(true) .require_equals(true) @@ -953,7 +953,7 @@ pub fn uu_app() -> clap::App<'static, 'static> { .help("(alternatively of=FILE) specifies the file used for output. When not specified, stdout is used instead") ) .arg( - clap::Arg::with_name(options::IBS) + Arg::new(options::IBS) .long(options::IBS) .takes_value(true) .require_equals(true) @@ -961,7 +961,7 @@ pub fn uu_app() -> clap::App<'static, 'static> { .help("(alternatively ibs=N) specifies the size of buffer used for reads (default: 512). Multiplier strings permitted.") ) .arg( - clap::Arg::with_name(options::OBS) + Arg::new(options::OBS) .long(options::OBS) .takes_value(true) .require_equals(true) @@ -969,7 +969,7 @@ pub fn uu_app() -> clap::App<'static, 'static> { .help("(alternatively obs=N) specifies the size of buffer used for writes (default: 512). Multiplier strings permitted.") ) .arg( - clap::Arg::with_name(options::BS) + Arg::new(options::BS) .long(options::BS) .takes_value(true) .require_equals(true) @@ -977,7 +977,7 @@ pub fn uu_app() -> clap::App<'static, 'static> { .help("(alternatively bs=N) specifies ibs=N and obs=N (default: 512). If ibs or obs are also specified, bs=N takes precedence. Multiplier strings permitted.") ) .arg( - clap::Arg::with_name(options::CBS) + Arg::new(options::CBS) .long(options::CBS) .takes_value(true) .require_equals(true) @@ -985,7 +985,7 @@ pub fn uu_app() -> clap::App<'static, 'static> { .help("(alternatively cbs=BYTES) specifies the 'conversion block size' in bytes. Applies to the conv=block, and conv=unblock operations. Multiplier strings permitted.") ) .arg( - clap::Arg::with_name(options::SKIP) + Arg::new(options::SKIP) .long(options::SKIP) .takes_value(true) .require_equals(true) @@ -993,7 +993,7 @@ pub fn uu_app() -> clap::App<'static, 'static> { .help("(alternatively skip=N) causes N ibs-sized records of input to be skipped before beginning copy/convert operations. See iflag=count_bytes if skipping N bytes is preferred. Multiplier strings permitted.") ) .arg( - clap::Arg::with_name(options::SEEK) + Arg::new(options::SEEK) .long(options::SEEK) .takes_value(true) .require_equals(true) @@ -1001,7 +1001,7 @@ pub fn uu_app() -> clap::App<'static, 'static> { .help("(alternatively seek=N) seeks N obs-sized records into output before beginning copy/convert operations. See oflag=seek_bytes if seeking N bytes is preferred. Multiplier strings permitted.") ) .arg( - clap::Arg::with_name(options::COUNT) + Arg::new(options::COUNT) .long(options::COUNT) .takes_value(true) .require_equals(true) @@ -1009,7 +1009,7 @@ pub fn uu_app() -> clap::App<'static, 'static> { .help("(alternatively count=N) stop reading input after N ibs-sized read operations rather than proceeding until EOF. See iflag=count_bytes if stopping after N bytes is preferred. Multiplier strings permitted.") ) .arg( - clap::Arg::with_name(options::STATUS) + Arg::new(options::STATUS) .long(options::STATUS) .takes_value(true) .require_equals(true) @@ -1033,7 +1033,7 @@ Printing performance stats is also triggered by the INFO signal (where supported ") ) .arg( - clap::Arg::with_name(options::CONV) + Arg::new(options::CONV) .long(options::CONV) .takes_value(true) .require_equals(true) @@ -1070,7 +1070,7 @@ Conversion Flags: ") ) .arg( - clap::Arg::with_name(options::IFLAG) + Arg::new(options::IFLAG) .long(options::IFLAG) .takes_value(true) .require_equals(true) @@ -1096,7 +1096,7 @@ General-Flags ") ) .arg( - clap::Arg::with_name(options::OFLAG) + Arg::new(options::OFLAG) .long(options::OFLAG) .takes_value(true) .require_equals(true) diff --git a/src/uu/dd/src/dd_unit_tests/sanity_tests.rs b/src/uu/dd/src/dd_unit_tests/sanity_tests.rs index edf25fe5d..f58d68c48 100644 --- a/src/uu/dd/src/dd_unit_tests/sanity_tests.rs +++ b/src/uu/dd/src/dd_unit_tests/sanity_tests.rs @@ -311,6 +311,6 @@ fn test_nocreat_causes_failure_when_ofile_doesnt_exist() { String::from("--of=not-a-real.file"), ]; - let matches = uu_app().get_matches_from_safe(args).unwrap(); + let matches = uu_app().try_get_matches_from(args).unwrap(); let _ = Output::::new(&matches).unwrap(); } diff --git a/src/uu/dd/src/parseargs.rs b/src/uu/dd/src/parseargs.rs index ef2d5f356..06cdeff25 100644 --- a/src/uu/dd/src/parseargs.rs +++ b/src/uu/dd/src/parseargs.rs @@ -13,7 +13,7 @@ use super::*; use std::error::Error; use uucore::error::UError; -pub type Matches = clap::ArgMatches<'static>; +pub type Matches = ArgMatches; /// Parser Errors describe errors with parser input #[derive(Debug, PartialEq)] diff --git a/src/uu/dd/src/parseargs/unit_tests.rs b/src/uu/dd/src/parseargs/unit_tests.rs index 21900ee49..3ee949805 100644 --- a/src/uu/dd/src/parseargs/unit_tests.rs +++ b/src/uu/dd/src/parseargs/unit_tests.rs @@ -25,7 +25,7 @@ fn unimplemented_flags_should_error_non_linux() { format!("--iflag={}", flag), format!("--oflag={}", flag), ]; - let matches = uu_app().get_matches_from_safe(args).unwrap(); + let matches = uu_app().try_get_matches_from(args).unwrap(); if parse_iflags(&matches).is_ok() { succeeded.push(format!("iflag={}", flag)); @@ -53,7 +53,7 @@ fn unimplemented_flags_should_error() { format!("--iflag={}", flag), format!("--oflag={}", flag), ]; - let matches = uu_app().get_matches_from_safe(args).unwrap(); + let matches = uu_app().try_get_matches_from(args).unwrap(); if parse_iflags(&matches).is_ok() { succeeded.push(format!("iflag={}", flag)) @@ -78,7 +78,7 @@ fn test_status_level_absent() { String::from("--of=bar.file"), ]; - let matches = uu_app().get_matches_from_safe(args).unwrap(); + let matches = uu_app().try_get_matches_from(args).unwrap(); let st = parse_status_level(&matches).unwrap(); assert_eq!(st, None); @@ -93,7 +93,7 @@ fn test_status_level_none() { String::from("--of=bar.file"), ]; - let matches = uu_app().get_matches_from_safe(args).unwrap(); + let matches = uu_app().try_get_matches_from(args).unwrap(); let st = parse_status_level(&matches).unwrap().unwrap(); assert_eq!(st, StatusLevel::None); @@ -121,7 +121,7 @@ fn test_all_top_level_args_no_leading_dashes() { .into_iter() .fold(Vec::new(), append_dashes_if_not_present); - let matches = uu_app().get_matches_from_safe(args).unwrap(); + let matches = uu_app().try_get_matches_from(args).unwrap(); assert_eq!(100, parse_ibs(&matches).unwrap()); assert_eq!(100, parse_obs(&matches).unwrap()); @@ -205,7 +205,7 @@ fn test_all_top_level_args_with_leading_dashes() { .into_iter() .fold(Vec::new(), append_dashes_if_not_present); - let matches = uu_app().get_matches_from_safe(args).unwrap(); + let matches = uu_app().try_get_matches_from(args).unwrap(); assert_eq!(100, parse_ibs(&matches).unwrap()); assert_eq!(100, parse_obs(&matches).unwrap()); @@ -276,7 +276,7 @@ fn test_status_level_progress() { String::from("--status=progress"), ]; - let matches = uu_app().get_matches_from_safe(args).unwrap(); + let matches = uu_app().try_get_matches_from(args).unwrap(); let st = parse_status_level(&matches).unwrap().unwrap(); assert_eq!(st, StatusLevel::Progress); @@ -291,7 +291,7 @@ fn test_status_level_noxfer() { String::from("--of=bar.file"), ]; - let matches = uu_app().get_matches_from_safe(args).unwrap(); + let matches = uu_app().try_get_matches_from(args).unwrap(); let st = parse_status_level(&matches).unwrap().unwrap(); assert_eq!(st, StatusLevel::Noxfer); @@ -304,7 +304,7 @@ fn test_status_level_noxfer() { fn icf_ctable_error() { let args = vec![String::from("dd"), String::from("--conv=ascii,ebcdic,ibm")]; - let matches = uu_app().get_matches_from_safe(args).unwrap(); + let matches = uu_app().try_get_matches_from(args).unwrap(); let _ = parse_conv_flag_input(&matches).unwrap(); } @@ -314,7 +314,7 @@ fn icf_ctable_error() { fn icf_case_error() { let args = vec![String::from("dd"), String::from("--conv=ucase,lcase")]; - let matches = uu_app().get_matches_from_safe(args).unwrap(); + let matches = uu_app().try_get_matches_from(args).unwrap(); let _ = parse_conv_flag_input(&matches).unwrap(); } @@ -324,7 +324,7 @@ fn icf_case_error() { fn icf_block_error() { let args = vec![String::from("dd"), String::from("--conv=block,unblock")]; - let matches = uu_app().get_matches_from_safe(args).unwrap(); + let matches = uu_app().try_get_matches_from(args).unwrap(); let _ = parse_conv_flag_input(&matches).unwrap(); } @@ -334,7 +334,7 @@ fn icf_block_error() { fn icf_creat_error() { let args = vec![String::from("dd"), String::from("--conv=excl,nocreat")]; - let matches = uu_app().get_matches_from_safe(args).unwrap(); + let matches = uu_app().try_get_matches_from(args).unwrap(); let _ = parse_conv_flag_output(&matches).unwrap(); } @@ -344,7 +344,7 @@ fn parse_icf_token_ibm() { let exp = vec![ConvFlag::FmtAtoI]; let args = vec![String::from("dd"), String::from("--conv=ibm")]; - let matches = uu_app().get_matches_from_safe(args).unwrap(); + let matches = uu_app().try_get_matches_from(args).unwrap(); let act = parse_flag_list::("conv", &matches).unwrap(); @@ -362,7 +362,7 @@ fn parse_icf_tokens_elu() { String::from("dd"), String::from("--conv=ebcdic,lcase,unblock"), ]; - let matches = uu_app().get_matches_from_safe(args).unwrap(); + let matches = uu_app().try_get_matches_from(args).unwrap(); let act = parse_flag_list::("conv", &matches).unwrap(); assert_eq!(exp.len(), act.len()); @@ -393,7 +393,7 @@ fn parse_icf_tokens_remaining() { String::from("dd"), String::from("--conv=ascii,ucase,block,sparse,swab,sync,noerror,excl,nocreat,notrunc,noerror,fdatasync,fsync"), ]; - let matches = uu_app().get_matches_from_safe(args).unwrap(); + let matches = uu_app().try_get_matches_from(args).unwrap(); let act = parse_flag_list::("conv", &matches).unwrap(); @@ -417,7 +417,7 @@ fn parse_iflag_tokens() { String::from("dd"), String::from("--iflag=fullblock,count_bytes,skip_bytes,append,seek_bytes"), ]; - let matches = uu_app().get_matches_from_safe(args).unwrap(); + let matches = uu_app().try_get_matches_from(args).unwrap(); let act = parse_flag_list::("iflag", &matches).unwrap(); @@ -441,7 +441,7 @@ fn parse_oflag_tokens() { String::from("dd"), String::from("--oflag=fullblock,count_bytes,skip_bytes,append,seek_bytes"), ]; - let matches = uu_app().get_matches_from_safe(args).unwrap(); + let matches = uu_app().try_get_matches_from(args).unwrap(); let act = parse_flag_list::("oflag", &matches).unwrap(); @@ -469,7 +469,7 @@ fn parse_iflag_tokens_linux() { String::from("dd"), String::from("--iflag=direct,directory,dsync,sync,nonblock,noatime,noctty,nofollow"), ]; - let matches = uu_app().get_matches_from_safe(args).unwrap(); + let matches = uu_app().try_get_matches_from(args).unwrap(); let act = parse_flag_list::("iflag", &matches).unwrap(); @@ -497,7 +497,7 @@ fn parse_oflag_tokens_linux() { String::from("dd"), String::from("--oflag=direct,directory,dsync,sync,nonblock,noatime,noctty,nofollow"), ]; - let matches = uu_app().get_matches_from_safe(args).unwrap(); + let matches = uu_app().try_get_matches_from(args).unwrap(); let act = parse_flag_list::("oflag", &matches).unwrap(); diff --git a/src/uu/df/Cargo.toml b/src/uu/df/Cargo.toml index cae0d9176..d0929f9fa 100644 --- a/src/uu/df/Cargo.toml +++ b/src/uu/df/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_df" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "df ~ (uutils) display file system information" @@ -15,7 +15,7 @@ edition = "2018" path = "src/df.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } number_prefix = "0.4" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["libc", "fsext"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/df/src/df.rs b/src/uu/df/src/df.rs index 2f703542c..b5bdf5c45 100644 --- a/src/uu/df/src/df.rs +++ b/src/uu/df/src/df.rs @@ -280,7 +280,7 @@ impl UError for DfError { #[uucore_procs::gen_uumain] pub fn uumain(args: impl uucore::Args) -> UResult<()> { 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 paths: Vec = matches .values_of(OPT_PATHS) @@ -421,19 +421,19 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(OPT_ALL) - .short("a") + Arg::new(OPT_ALL) + .short('a') .long("all") .help("include dummy file systems"), ) .arg( - Arg::with_name(OPT_BLOCKSIZE) - .short("B") + Arg::new(OPT_BLOCKSIZE) + .short('B') .long("block-size") .takes_value(true) .help( @@ -442,54 +442,50 @@ pub fn uu_app() -> App<'static, 'static> { ), ) .arg( - Arg::with_name(OPT_DIRECT) + Arg::new(OPT_DIRECT) .long("direct") .help("show statistics for a file instead of mount point"), ) .arg( - Arg::with_name(OPT_TOTAL) + Arg::new(OPT_TOTAL) .long("total") .help("produce a grand total"), ) .arg( - Arg::with_name(OPT_HUMAN_READABLE) - .short("h") + Arg::new(OPT_HUMAN_READABLE) + .short('h') .long("human-readable") .conflicts_with(OPT_HUMAN_READABLE_2) .help("print sizes in human readable format (e.g., 1K 234M 2G)"), ) .arg( - Arg::with_name(OPT_HUMAN_READABLE_2) - .short("H") + Arg::new(OPT_HUMAN_READABLE_2) + .short('H') .long("si") .conflicts_with(OPT_HUMAN_READABLE) .help("likewise, but use powers of 1000 not 1024"), ) .arg( - Arg::with_name(OPT_INODES) - .short("i") + Arg::new(OPT_INODES) + .short('i') .long("inodes") .help("list inode information instead of block usage"), ) + .arg(Arg::new(OPT_KILO).short('k').help("like --block-size=1K")) .arg( - Arg::with_name(OPT_KILO) - .short("k") - .help("like --block-size=1K"), - ) - .arg( - Arg::with_name(OPT_LOCAL) - .short("l") + Arg::new(OPT_LOCAL) + .short('l') .long("local") .help("limit listing to local file systems"), ) .arg( - Arg::with_name(OPT_NO_SYNC) + Arg::new(OPT_NO_SYNC) .long("no-sync") .conflicts_with(OPT_SYNC) .help("do not invoke sync before getting usage info (default)"), ) .arg( - Arg::with_name(OPT_OUTPUT) + Arg::new(OPT_OUTPUT) .long("output") .takes_value(true) .use_delimiter(true) @@ -499,39 +495,40 @@ pub fn uu_app() -> App<'static, 'static> { ), ) .arg( - Arg::with_name(OPT_PORTABILITY) - .short("P") + Arg::new(OPT_PORTABILITY) + .short('P') .long("portability") .help("use the POSIX output format"), ) .arg( - Arg::with_name(OPT_SYNC) + Arg::new(OPT_SYNC) .long("sync") .conflicts_with(OPT_NO_SYNC) .help("invoke sync before getting usage info"), ) .arg( - Arg::with_name(OPT_TYPE) - .short("t") + Arg::new(OPT_TYPE) + .short('t') .long("type") + .allow_invalid_utf8(true) .takes_value(true) .use_delimiter(true) .help("limit listing to file systems of type TYPE"), ) .arg( - Arg::with_name(OPT_PRINT_TYPE) - .short("T") + Arg::new(OPT_PRINT_TYPE) + .short('T') .long("print-type") .help("print file system type"), ) .arg( - Arg::with_name(OPT_EXCLUDE_TYPE) - .short("x") + Arg::new(OPT_EXCLUDE_TYPE) + .short('x') .long("exclude-type") .takes_value(true) .use_delimiter(true) .help("limit listing to file systems not of type TYPE"), ) - .arg(Arg::with_name(OPT_PATHS).multiple(true)) - .help("Filesystem(s) to list") + .arg(Arg::new(OPT_PATHS).multiple_occurrences(true)) + .override_help("Filesystem(s) to list") } diff --git a/src/uu/dircolors/Cargo.toml b/src/uu/dircolors/Cargo.toml index 9ea18b963..0f752060b 100644 --- a/src/uu/dircolors/Cargo.toml +++ b/src/uu/dircolors/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_dircolors" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "dircolors ~ (uutils) display commands to set LS_COLORS" @@ -15,7 +15,7 @@ edition = "2018" path = "src/dircolors.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } glob = "0.3.0" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/dircolors/src/dircolors.rs b/src/uu/dircolors/src/dircolors.rs index 270e62aca..2ef0d3e39 100644 --- a/src/uu/dircolors/src/dircolors.rs +++ b/src/uu/dircolors/src/dircolors.rs @@ -73,7 +73,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { 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 files = matches .values_of(options::FILE) @@ -160,35 +160,39 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(SUMMARY) .after_help(LONG_HELP) .arg( - Arg::with_name(options::BOURNE_SHELL) + Arg::new(options::BOURNE_SHELL) .long("sh") - .short("b") + .short('b') .visible_alias("bourne-shell") .help("output Bourne shell code to set LS_COLORS") .display_order(1), ) .arg( - Arg::with_name(options::C_SHELL) + Arg::new(options::C_SHELL) .long("csh") - .short("c") + .short('c') .visible_alias("c-shell") .help("output C shell code to set LS_COLORS") .display_order(2), ) .arg( - Arg::with_name(options::PRINT_DATABASE) + Arg::new(options::PRINT_DATABASE) .long("print-database") - .short("p") + .short('p') .help("print the byte counts") .display_order(3), ) - .arg(Arg::with_name(options::FILE).hidden(true).multiple(true)) + .arg( + Arg::new(options::FILE) + .hide(true) + .multiple_occurrences(true), + ) } pub trait StrUtils { diff --git a/src/uu/dirname/Cargo.toml b/src/uu/dirname/Cargo.toml index a0e99d8ea..e17ac95ac 100644 --- a/src/uu/dirname/Cargo.toml +++ b/src/uu/dirname/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_dirname" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "dirname ~ (uutils) display parent directory of PATHNAME" @@ -15,7 +15,7 @@ edition = "2018" path = "src/dirname.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/dirname/src/dirname.rs b/src/uu/dirname/src/dirname.rs index 129c9369e..ce1e9423b 100644 --- a/src/uu/dirname/src/dirname.rs +++ b/src/uu/dirname/src/dirname.rs @@ -39,7 +39,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let after_help = get_long_usage(); let matches = uu_app() - .usage(&usage[..]) + .override_usage(&usage[..]) .after_help(&after_help[..]) .get_matches_from(args); @@ -83,15 +83,15 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .about(ABOUT) .version(crate_version!()) .arg( - Arg::with_name(options::ZERO) + Arg::new(options::ZERO) .long(options::ZERO) - .short("z") + .short('z') .help("separate output with NUL rather than newline"), ) - .arg(Arg::with_name(options::DIR).hidden(true).multiple(true)) + .arg(Arg::new(options::DIR).hide(true).multiple_occurrences(true)) } diff --git a/src/uu/du/Cargo.toml b/src/uu/du/Cargo.toml index b4bbdab1d..5fd85640b 100644 --- a/src/uu/du/Cargo.toml +++ b/src/uu/du/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_du" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "du ~ (uutils) display disk usage" @@ -15,8 +15,8 @@ edition = "2018" path = "src/du.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } chrono = "^0.4.11" +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/du/src/du.rs b/src/uu/du/src/du.rs index 58d01701f..d33e43325 100644 --- a/src/uu/du/src/du.rs +++ b/src/uu/du/src/du.rs @@ -462,7 +462,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { 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); @@ -625,19 +625,19 @@ fn parse_depth(max_depth_str: Option<&str>, summarize: bool) -> UResult App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(SUMMARY) .after_help(LONG_HELP) .arg( - Arg::with_name(options::ALL) - .short("a") + Arg::new(options::ALL) + .short('a') .long(options::ALL) .help("write counts for all files, not just directories"), ) .arg( - Arg::with_name(options::APPARENT_SIZE) + Arg::new(options::APPARENT_SIZE) .long(options::APPARENT_SIZE) .help( "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 ) .arg( - Arg::with_name(options::BLOCK_SIZE) - .short("B") + Arg::new(options::BLOCK_SIZE) + .short('B') .long(options::BLOCK_SIZE) .value_name("SIZE") .help( @@ -657,20 +657,20 @@ pub fn uu_app() -> App<'static, 'static> { ) ) .arg( - Arg::with_name(options::BYTES) - .short("b") + Arg::new(options::BYTES) + .short('b') .long("bytes") .help("equivalent to '--apparent-size --block-size=1'") ) .arg( - Arg::with_name(options::TOTAL) + Arg::new(options::TOTAL) .long("total") - .short("c") + .short('c') .help("produce a grand total") ) .arg( - Arg::with_name(options::MAX_DEPTH) - .short("d") + Arg::new(options::MAX_DEPTH) + .short('d') .long("max-depth") .value_name("N") .help( @@ -680,78 +680,78 @@ pub fn uu_app() -> App<'static, 'static> { ) ) .arg( - Arg::with_name(options::HUMAN_READABLE) + Arg::new(options::HUMAN_READABLE) .long("human-readable") - .short("h") + .short('h') .help("print sizes in human readable format (e.g., 1K 234M 2G)") ) .arg( - Arg::with_name(options::INODES) + Arg::new(options::INODES) .long(options::INODES) .help( "list inode usage information instead of block usage like --block-size=1K" ) ) .arg( - Arg::with_name(options::BLOCK_SIZE_1K) - .short("k") + Arg::new(options::BLOCK_SIZE_1K) + .short('k') .help("like --block-size=1K") ) .arg( - Arg::with_name(options::COUNT_LINKS) - .short("l") + Arg::new(options::COUNT_LINKS) + .short('l') .long("count-links") .help("count sizes many times if hard linked") ) .arg( - Arg::with_name(options::DEREFERENCE) - .short("L") + Arg::new(options::DEREFERENCE) + .short('L') .long(options::DEREFERENCE) .help("dereference all symbolic links") ) // .arg( - // Arg::with_name("no-dereference") - // .short("P") + // Arg::new("no-dereference") + // .short('P') // .long("no-dereference") // .help("don't follow any symbolic links (this is the default)") // ) .arg( - Arg::with_name(options::BLOCK_SIZE_1M) - .short("m") + Arg::new(options::BLOCK_SIZE_1M) + .short('m') .help("like --block-size=1M") ) .arg( - Arg::with_name(options::NULL) - .short("0") + Arg::new(options::NULL) + .short('0') .long("null") .help("end each output line with 0 byte rather than newline") ) .arg( - Arg::with_name(options::SEPARATE_DIRS) - .short("S") + Arg::new(options::SEPARATE_DIRS) + .short('S') .long("separate-dirs") .help("do not include size of subdirectories") ) .arg( - Arg::with_name(options::SUMMARIZE) - .short("s") + Arg::new(options::SUMMARIZE) + .short('s') .long("summarize") .help("display only a total for each argument") ) .arg( - Arg::with_name(options::SI) + Arg::new(options::SI) .long(options::SI) .help("like -h, but use powers of 1000 not 1024") ) .arg( - Arg::with_name(options::ONE_FILE_SYSTEM) - .short("x") + Arg::new(options::ONE_FILE_SYSTEM) + .short('x') .long(options::ONE_FILE_SYSTEM) .help("skip directories on different file systems") ) .arg( - Arg::with_name(options::THRESHOLD) - .short("t") + Arg::new(options::THRESHOLD) + .short('t') .long(options::THRESHOLD) .alias("th") .value_name("SIZE") @@ -761,20 +761,20 @@ pub fn uu_app() -> App<'static, 'static> { or entries greater than SIZE if negative") ) // .arg( - // Arg::with_name("") - // .short("x") + // Arg::new("") + // .short('x') // .long("exclude-from") // .value_name("FILE") // .help("exclude files that match any pattern in FILE") // ) // .arg( - // Arg::with_name("exclude") + // Arg::new("exclude") // .long("exclude") // .value_name("PATTERN") // .help("exclude files that match PATTERN") // ) .arg( - Arg::with_name(options::TIME) + Arg::new(options::TIME) .long(options::TIME) .value_name("WORD") .require_equals(true) @@ -787,7 +787,7 @@ pub fn uu_app() -> App<'static, 'static> { ) ) .arg( - Arg::with_name(options::TIME_STYLE) + Arg::new(options::TIME_STYLE) .long(options::TIME_STYLE) .value_name("STYLE") .help( @@ -796,9 +796,9 @@ pub fn uu_app() -> App<'static, 'static> { ) ) .arg( - Arg::with_name(options::FILE) - .hidden(true) - .multiple(true) + Arg::new(options::FILE) + .hide(true) + .multiple_occurrences(true) ) } diff --git a/src/uu/echo/Cargo.toml b/src/uu/echo/Cargo.toml index c9fad93c7..be97527d9 100644 --- a/src/uu/echo/Cargo.toml +++ b/src/uu/echo/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_echo" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "echo ~ (uutils) display TEXT" @@ -15,7 +15,7 @@ edition = "2018" path = "src/echo.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/echo/src/echo.rs b/src/uu/echo/src/echo.rs index a0e6c0d9c..5eda9d5b1 100644 --- a/src/uu/echo/src/echo.rs +++ b/src/uu/echo/src/echo.rs @@ -128,44 +128,37 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { execute(no_newline, escaped, values).map_err_context(|| "could not write to stdout".to_string()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .name(NAME) // TrailingVarArg specifies the final positional argument is a VarArg // and it doesn't attempts the parse any further args. // Final argument must have multiple(true) or the usage string equivalent. .setting(clap::AppSettings::TrailingVarArg) - .setting(clap::AppSettings::AllowLeadingHyphen) + .setting(clap::AppSettings::AllowHyphenValues) .version(crate_version!()) .about(SUMMARY) .after_help(AFTER_HELP) - .usage(USAGE) + .override_usage(USAGE) .arg( - Arg::with_name(options::NO_NEWLINE) - .short("n") + Arg::new(options::NO_NEWLINE) + .short('n') .help("do not output the trailing newline") - .takes_value(false) - .display_order(1), + .takes_value(false), ) .arg( - Arg::with_name(options::ENABLE_BACKSLASH_ESCAPE) - .short("e") + Arg::new(options::ENABLE_BACKSLASH_ESCAPE) + .short('e') .help("enable interpretation of backslash escapes") - .takes_value(false) - .display_order(2), + .takes_value(false), ) .arg( - Arg::with_name(options::DISABLE_BACKSLASH_ESCAPE) - .short("E") + Arg::new(options::DISABLE_BACKSLASH_ESCAPE) + .short('E') .help("disable interpretation of backslash escapes (default)") - .takes_value(false) - .display_order(3), - ) - .arg( - Arg::with_name(options::STRING) - .multiple(true) - .allow_hyphen_values(true), + .takes_value(false), ) + .arg(Arg::new(options::STRING).multiple_occurrences(true)) } fn execute(no_newline: bool, escaped: bool, free: Vec) -> io::Result<()> { diff --git a/src/uu/env/Cargo.toml b/src/uu/env/Cargo.toml index 172c8feba..d6ded5d46 100644 --- a/src/uu/env/Cargo.toml +++ b/src/uu/env/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_env" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "env ~ (uutils) set each NAME to VALUE in the environment and run COMMAND" @@ -15,7 +15,7 @@ edition = "2018" path = "src/env.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" rust-ini = "0.17.0" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/env/src/env.rs b/src/uu/env/src/env.rs index 55dfce625..639887ee0 100644 --- a/src/uu/env/src/env.rs +++ b/src/uu/env/src/env.rs @@ -119,46 +119,46 @@ fn build_command<'a, 'b>(args: &'a mut Vec<&'b str>) -> (Cow<'b, str>, &'a [&'b (progname, &args[..]) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(crate_name!()) .version(crate_version!()) .author(crate_authors!()) .about(crate_description!()) - .usage(USAGE) + .override_usage(USAGE) .after_help(AFTER_HELP) .setting(AppSettings::AllowExternalSubcommands) - .arg(Arg::with_name("ignore-environment") - .short("i") + .arg(Arg::new("ignore-environment") + .short('i') .long("ignore-environment") .help("start with an empty environment")) - .arg(Arg::with_name("chdir") - .short("C") // GNU env compatibility + .arg(Arg::new("chdir") + .short('C') // GNU env compatibility .long("chdir") .takes_value(true) .number_of_values(1) .value_name("DIR") .help("change working directory to DIR")) - .arg(Arg::with_name("null") - .short("0") + .arg(Arg::new("null") + .short('0') .long("null") .help("end each output line with a 0 byte rather than a newline (only valid when \ printing the environment)")) - .arg(Arg::with_name("file") - .short("f") + .arg(Arg::new("file") + .short('f') .long("file") .takes_value(true) .number_of_values(1) .value_name("PATH") - .multiple(true) + .multiple_occurrences(true) .help("read and set variables from a \".env\"-style configuration file (prior to any \ unset and/or set)")) - .arg(Arg::with_name("unset") - .short("u") + .arg(Arg::new("unset") + .short('u') .long("unset") .takes_value(true) .number_of_values(1) .value_name("NAME") - .multiple(true) + .multiple_occurrences(true) .help("remove variable from the environment")) } @@ -203,7 +203,7 @@ fn run_env(args: impl uucore::Args) -> UResult<()> { // we handle the name, value pairs and the program to be executed by treating them as external // subcommands in clap - if let (external, Some(matches)) = matches.subcommand() { + if let Some((external, matches)) = matches.subcommand() { let mut begin_prog_opts = false; if external == "-" { diff --git a/src/uu/expand/Cargo.toml b/src/uu/expand/Cargo.toml index 0a2846f4b..269486184 100644 --- a/src/uu/expand/Cargo.toml +++ b/src/uu/expand/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_expand" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "expand ~ (uutils) convert input tabs to spaces" @@ -15,7 +15,7 @@ edition = "2018" path = "src/expand.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } unicode-width = "0.1.5" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/expand/src/expand.rs b/src/uu/expand/src/expand.rs index 425179092..8528593f9 100644 --- a/src/uu/expand/src/expand.rs +++ b/src/uu/expand/src/expand.rs @@ -174,39 +174,39 @@ impl Options { #[uucore_procs::gen_uumain] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); - let matches = uu_app().usage(&usage[..]).get_matches_from(args); + let matches = uu_app().override_usage(&usage[..]).get_matches_from(args); expand(Options::new(&matches)).map_err_context(|| "failed to write output".to_string()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .after_help(LONG_HELP) .arg( - Arg::with_name(options::INITIAL) + Arg::new(options::INITIAL) .long(options::INITIAL) - .short("i") + .short('i') .help("do not convert tabs after non blanks"), ) .arg( - Arg::with_name(options::TABS) + Arg::new(options::TABS) .long(options::TABS) - .short("t") + .short('t') .value_name("N, LIST") .takes_value(true) .help("have tabs N characters apart, not 8 or use comma separated list of explicit tab positions"), ) .arg( - Arg::with_name(options::NO_UTF8) + Arg::new(options::NO_UTF8) .long(options::NO_UTF8) - .short("U") + .short('U') .help("interpret input file as 8-bit ASCII rather than UTF-8"), ).arg( - Arg::with_name(options::FILES) - .multiple(true) - .hidden(true) + Arg::new(options::FILES) + .multiple_occurrences(true) + .hide(true) .takes_value(true) ) } diff --git a/src/uu/expr/Cargo.toml b/src/uu/expr/Cargo.toml index 3982b90f5..aac7204e7 100644 --- a/src/uu/expr/Cargo.toml +++ b/src/uu/expr/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_expr" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "expr ~ (uutils) display the value of EXPRESSION" @@ -15,7 +15,7 @@ edition = "2018" path = "src/expr.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" num-bigint = "0.4.0" num-traits = "0.2.14" diff --git a/src/uu/expr/src/expr.rs b/src/uu/expr/src/expr.rs index 6e2a8701a..8acd00d62 100644 --- a/src/uu/expr/src/expr.rs +++ b/src/uu/expr/src/expr.rs @@ -15,10 +15,10 @@ mod tokens; const VERSION: &str = "version"; const HELP: &str = "help"; -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) - .arg(Arg::with_name(VERSION).long(VERSION)) - .arg(Arg::with_name(HELP).long(HELP)) + .arg(Arg::new(VERSION).long(VERSION)) + .arg(Arg::new(HELP).long(HELP)) } #[uucore_procs::gen_uumain] diff --git a/src/uu/factor/Cargo.toml b/src/uu/factor/Cargo.toml index 2583fafcb..d38f82f8e 100644 --- a/src/uu/factor/Cargo.toml +++ b/src/uu/factor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_factor" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "factor ~ (uutils) display the prime factors of each NUMBER" @@ -15,7 +15,7 @@ edition = "2018" num-traits = "0.2.13" # used in src/numerics.rs, which is included by build.rs [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } coz = { version = "0.1.3", optional = true } num-traits = "0.2.13" # Needs at least version 0.2.13 for "OverflowingAdd" rand = { version = "0.7", features = ["small_rng"] } diff --git a/src/uu/factor/src/cli.rs b/src/uu/factor/src/cli.rs index 0aa0b2474..653fbd404 100644 --- a/src/uu/factor/src/cli.rs +++ b/src/uu/factor/src/cli.rs @@ -77,9 +77,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(SUMMARY) - .arg(Arg::with_name(options::NUMBER).multiple(true)) + .arg(Arg::new(options::NUMBER).multiple_occurrences(true)) } diff --git a/src/uu/false/Cargo.toml b/src/uu/false/Cargo.toml index 41b20c1a9..cc7e9c517 100644 --- a/src/uu/false/Cargo.toml +++ b/src/uu/false/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_false" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "false ~ (uutils) do nothing and fail" @@ -15,7 +15,7 @@ edition = "2018" path = "src/false.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/false/src/false.rs b/src/uu/false/src/false.rs index 783c7fa0d..a75770728 100644 --- a/src/uu/false/src/false.rs +++ b/src/uu/false/src/false.rs @@ -14,6 +14,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Err(1.into()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) } diff --git a/src/uu/fmt/Cargo.toml b/src/uu/fmt/Cargo.toml index 70ff36a9a..6b6f551ca 100644 --- a/src/uu/fmt/Cargo.toml +++ b/src/uu/fmt/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_fmt" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "fmt ~ (uutils) reformat each paragraph of input" @@ -15,7 +15,7 @@ edition = "2018" path = "src/fmt.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" unicode-width = "0.1.5" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/fmt/src/fmt.rs b/src/uu/fmt/src/fmt.rs index 91fc08d28..4f1f0433b 100644 --- a/src/uu/fmt/src/fmt.rs +++ b/src/uu/fmt/src/fmt.rs @@ -71,7 +71,7 @@ pub struct FmtOptions { pub fn uumain(args: impl uucore::Args) -> UResult<()> { 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 mut files: Vec = matches .values_of(ARG_FILES) @@ -222,13 +222,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(OPT_CROWN_MARGIN) - .short("c") + Arg::new(OPT_CROWN_MARGIN) + .short('c') .long(OPT_CROWN_MARGIN) .help( "First and second line of paragraph \ @@ -238,8 +238,8 @@ pub fn uu_app() -> App<'static, 'static> { ), ) .arg( - Arg::with_name(OPT_TAGGED_PARAGRAPH) - .short("t") + Arg::new(OPT_TAGGED_PARAGRAPH) + .short('t') .long("tagged-paragraph") .help( "Like -c, except that the first and second line of a paragraph *must* \ @@ -247,8 +247,8 @@ pub fn uu_app() -> App<'static, 'static> { ), ) .arg( - Arg::with_name(OPT_PRESERVE_HEADERS) - .short("m") + Arg::new(OPT_PRESERVE_HEADERS) + .short('m') .long("preserve-headers") .help( "Attempt to detect and preserve mail headers in the input. \ @@ -256,14 +256,14 @@ pub fn uu_app() -> App<'static, 'static> { ), ) .arg( - Arg::with_name(OPT_SPLIT_ONLY) - .short("s") + Arg::new(OPT_SPLIT_ONLY) + .short('s') .long("split-only") .help("Split lines only, do not reflow."), ) .arg( - Arg::with_name(OPT_UNIFORM_SPACING) - .short("u") + Arg::new(OPT_UNIFORM_SPACING) + .short('u') .long("uniform-spacing") .help( "Insert exactly one \ @@ -274,8 +274,8 @@ pub fn uu_app() -> App<'static, 'static> { ), ) .arg( - Arg::with_name(OPT_PREFIX) - .short("p") + Arg::new(OPT_PREFIX) + .short('p') .long("prefix") .help( "Reformat only lines \ @@ -286,8 +286,8 @@ pub fn uu_app() -> App<'static, 'static> { .value_name("PREFIX"), ) .arg( - Arg::with_name(OPT_SKIP_PREFIX) - .short("P") + Arg::new(OPT_SKIP_PREFIX) + .short('P') .long("skip-prefix") .help( "Do not reformat lines \ @@ -297,8 +297,8 @@ pub fn uu_app() -> App<'static, 'static> { .value_name("PSKIP"), ) .arg( - Arg::with_name(OPT_EXACT_PREFIX) - .short("x") + Arg::new(OPT_EXACT_PREFIX) + .short('x') .long("exact-prefix") .help( "PREFIX must match at the \ @@ -306,8 +306,8 @@ pub fn uu_app() -> App<'static, 'static> { ), ) .arg( - Arg::with_name(OPT_EXACT_SKIP_PREFIX) - .short("X") + Arg::new(OPT_EXACT_SKIP_PREFIX) + .short('X') .long("exact-skip-prefix") .help( "PSKIP must match at the \ @@ -315,26 +315,26 @@ pub fn uu_app() -> App<'static, 'static> { ), ) .arg( - Arg::with_name(OPT_WIDTH) - .short("w") + Arg::new(OPT_WIDTH) + .short('w') .long("width") .help("Fill output lines up to a maximum of WIDTH columns, default 79.") .value_name("WIDTH"), ) .arg( - Arg::with_name(OPT_GOAL) - .short("g") + Arg::new(OPT_GOAL) + .short('g') .long("goal") .help("Goal width, default ~0.94*WIDTH. Must be less than WIDTH.") .value_name("GOAL"), ) - .arg(Arg::with_name(OPT_QUICK).short("q").long("quick").help( + .arg(Arg::new(OPT_QUICK).short('q').long("quick").help( "Break lines more quickly at the \ expense of a potentially more ragged appearance.", )) .arg( - Arg::with_name(OPT_TAB_WIDTH) - .short("T") + Arg::new(OPT_TAB_WIDTH) + .short('T') .long("tab-width") .help( "Treat tabs as TABWIDTH spaces for \ @@ -343,5 +343,9 @@ pub fn uu_app() -> App<'static, 'static> { ) .value_name("TABWIDTH"), ) - .arg(Arg::with_name(ARG_FILES).multiple(true).takes_value(true)) + .arg( + Arg::new(ARG_FILES) + .multiple_occurrences(true) + .takes_value(true), + ) } diff --git a/src/uu/fold/Cargo.toml b/src/uu/fold/Cargo.toml index 93295bf4a..e08a59cd3 100644 --- a/src/uu/fold/Cargo.toml +++ b/src/uu/fold/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_fold" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "fold ~ (uutils) wrap each line of input" @@ -15,7 +15,7 @@ edition = "2018" path = "src/fold.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/fold/src/fold.rs b/src/uu/fold/src/fold.rs index 30a1012af..31cdf53e0 100644 --- a/src/uu/fold/src/fold.rs +++ b/src/uu/fold/src/fold.rs @@ -63,16 +63,16 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { fold(files, bytes, spaces, width) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .name(NAME) .version(crate_version!()) - .usage(SYNTAX) + .override_usage(SYNTAX) .about(SUMMARY) .arg( - Arg::with_name(options::BYTES) + Arg::new(options::BYTES) .long(options::BYTES) - .short("b") + .short('b') .help( "count using bytes rather than columns (meaning control characters \ such as newline are not treated specially)", @@ -80,22 +80,26 @@ pub fn uu_app() -> App<'static, 'static> { .takes_value(false), ) .arg( - Arg::with_name(options::SPACES) + Arg::new(options::SPACES) .long(options::SPACES) - .short("s") + .short('s') .help("break lines at word boundaries rather than a hard cut-off") .takes_value(false), ) .arg( - Arg::with_name(options::WIDTH) + Arg::new(options::WIDTH) .long(options::WIDTH) - .short("w") + .short('w') .help("set WIDTH as the maximum line width rather than 80") .value_name("WIDTH") .allow_hyphen_values(true) .takes_value(true), ) - .arg(Arg::with_name(options::FILE).hidden(true).multiple(true)) + .arg( + Arg::new(options::FILE) + .hide(true) + .multiple_occurrences(true), + ) } fn handle_obsolete(args: &[String]) -> (Vec, Option) { diff --git a/src/uu/groups/Cargo.toml b/src/uu/groups/Cargo.toml index b9de13221..ca0fe74f6 100644 --- a/src/uu/groups/Cargo.toml +++ b/src/uu/groups/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_groups" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "groups ~ (uutils) display group memberships for USERNAME" @@ -15,9 +15,9 @@ edition = "2018" path = "src/groups.rs" [dependencies] +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "process"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } -clap = { version = "2.33", features = ["wrap_help"] } [[bin]] name = "groups" diff --git a/src/uu/groups/src/groups.rs b/src/uu/groups/src/groups.rs index 70980780d..fac12df99 100644 --- a/src/uu/groups/src/groups.rs +++ b/src/uu/groups/src/groups.rs @@ -73,7 +73,7 @@ fn infallible_gid2grp(gid: &u32) -> String { pub fn uumain(args: impl uucore::Args) -> UResult<()> { 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 users: Vec = matches .values_of(options::USERS) @@ -105,13 +105,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(options::USERS) - .multiple(true) + Arg::new(options::USERS) + .multiple_occurrences(true) .takes_value(true) .value_name(options::USERS), ) diff --git a/src/uu/hashsum/Cargo.toml b/src/uu/hashsum/Cargo.toml index 372fb6a16..5ce5fa8f6 100644 --- a/src/uu/hashsum/Cargo.toml +++ b/src/uu/hashsum/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_hashsum" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "hashsum ~ (uutils) display or check input digests" @@ -16,7 +16,7 @@ path = "src/hashsum.rs" [dependencies] digest = "0.6.1" -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } hex = "0.2.0" libc = "0.2.42" memchr = "2" diff --git a/src/uu/hashsum/src/hashsum.rs b/src/uu/hashsum/src/hashsum.rs index d4dacc298..989e0f7f3 100644 --- a/src/uu/hashsum/src/hashsum.rs +++ b/src/uu/hashsum/src/hashsum.rs @@ -74,9 +74,9 @@ fn is_custom_binary(program: &str) -> bool { } #[allow(clippy::cognitive_complexity)] -fn detect_algo<'a>( +fn detect_algo( program: &str, - matches: &ArgMatches<'a>, + matches: &ArgMatches, ) -> (&'static str, Box, usize) { let mut alg: Option> = None; let mut name: &'static str = ""; @@ -270,10 +270,8 @@ fn parse_bit_num(arg: &str) -> Result { arg.parse() } -fn is_valid_bit_num(arg: String) -> Result<(), String> { - parse_bit_num(&arg) - .map(|_| ()) - .map_err(|e| format!("{}", e)) +fn is_valid_bit_num(arg: &str) -> Result<(), String> { + parse_bit_num(arg).map(|_| ()).map_err(|e| format!("{}", e)) } #[uucore_procs::gen_uumain] @@ -292,7 +290,7 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> { let app = uu_app(&binary_name); - // FIXME: this should use get_matches_from_safe() and crash!(), but at the moment that just + // FIXME: this should use try_get_matches_from() and crash!(), but at the moment that just // causes "error: " to be printed twice (once from crash!() and once from clap). With // the current setup, the name of the utility is not printed, but I think this is at // least somewhat better from a user's perspective. @@ -333,7 +331,7 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app_common() -> App<'static, 'static> { +pub fn uu_app_common<'a>() -> App<'a> { #[cfg(windows)] const BINARY_HELP: &str = "read in binary mode (default)"; #[cfg(not(windows))] @@ -346,55 +344,55 @@ pub fn uu_app_common() -> App<'static, 'static> { .version(crate_version!()) .about("Compute and check message digests.") .arg( - Arg::with_name("binary") - .short("b") + Arg::new("binary") + .short('b') .long("binary") .help(BINARY_HELP), ) .arg( - Arg::with_name("check") - .short("c") + Arg::new("check") + .short('c') .long("check") .help("read hashsums from the FILEs and check them"), ) .arg( - Arg::with_name("tag") + Arg::new("tag") .long("tag") .help("create a BSD-style checksum"), ) .arg( - Arg::with_name("text") - .short("t") + Arg::new("text") + .short('t') .long("text") .help(TEXT_HELP) .conflicts_with("binary"), ) .arg( - Arg::with_name("quiet") - .short("q") + Arg::new("quiet") + .short('q') .long("quiet") .help("don't print OK for each successfully verified file"), ) .arg( - Arg::with_name("status") - .short("s") + Arg::new("status") + .short('s') .long("status") .help("don't output anything, status code shows success"), ) .arg( - Arg::with_name("strict") + Arg::new("strict") .long("strict") .help("exit non-zero for improperly formatted checksum lines"), ) .arg( - Arg::with_name("warn") - .short("w") + Arg::new("warn") + .short('w') .long("warn") .help("warn about improperly formatted checksum lines"), ) // Needed for variable-length output sums (e.g. SHAKE) .arg( - Arg::with_name("bits") + Arg::new("bits") .long("bits") .help("set the size of the output (only for SHAKE)") .takes_value(true) @@ -403,14 +401,15 @@ pub fn uu_app_common() -> App<'static, 'static> { .validator(is_valid_bit_num), ) .arg( - Arg::with_name("FILE") + Arg::new("FILE") .index(1) - .multiple(true) - .value_name("FILE"), + .multiple_occurrences(true) + .value_name("FILE") + .allow_invalid_utf8(true), ) } -pub fn uu_app_custom() -> App<'static, 'static> { +pub fn uu_app_custom<'a>() -> App<'a> { let mut app = uu_app_common(); let algorithms = &[ ("md5", "work with MD5"), @@ -436,14 +435,14 @@ pub fn uu_app_custom() -> App<'static, 'static> { ]; for (name, desc) in algorithms { - app = app.arg(Arg::with_name(name).long(name).help(desc)); + app = app.arg(Arg::new(*name).long(name).help(*desc)); } app } // hashsum is handled differently in build.rs, therefore this is not the same // as in other utilities. -fn uu_app(binary_name: &str) -> App<'static, 'static> { +fn uu_app<'a>(binary_name: &str) -> App<'a> { if !is_custom_binary(binary_name) { uu_app_custom() } else { diff --git a/src/uu/head/Cargo.toml b/src/uu/head/Cargo.toml index 6486d2b5c..db44ec51f 100644 --- a/src/uu/head/Cargo.toml +++ b/src/uu/head/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_head" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "head ~ (uutils) display the first lines of input" @@ -15,7 +15,7 @@ edition = "2018" path = "src/head.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } memchr = "2" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["ringbuffer"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/head/src/head.rs b/src/uu/head/src/head.rs index e3325d084..1a61d4cc4 100644 --- a/src/uu/head/src/head.rs +++ b/src/uu/head/src/head.rs @@ -3,10 +3,10 @@ // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. -// spell-checker:ignore (vars) zlines BUFWRITER +// spell-checker:ignore (vars) zlines BUFWRITER seekable use clap::{crate_version, App, Arg}; -use std::convert::TryFrom; +use std::convert::{TryFrom, TryInto}; use std::ffi::OsString; use std::io::{self, BufWriter, ErrorKind, Read, Seek, SeekFrom, Write}; use uucore::display::Quotable; @@ -42,14 +42,14 @@ use lines::zlines; use take::take_all_but; use take::take_lines; -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) - .usage(USAGE) + .override_usage(USAGE) .arg( - Arg::with_name(options::BYTES_NAME) - .short("c") + Arg::new(options::BYTES_NAME) + .short('c') .long("bytes") .value_name("[-]NUM") .takes_value(true) @@ -64,8 +64,8 @@ pub fn uu_app() -> App<'static, 'static> { .allow_hyphen_values(true), ) .arg( - Arg::with_name(options::LINES_NAME) - .short("n") + Arg::new(options::LINES_NAME) + .short('n') .long("lines") .value_name("[-]NUM") .takes_value(true) @@ -80,28 +80,28 @@ pub fn uu_app() -> App<'static, 'static> { .allow_hyphen_values(true), ) .arg( - Arg::with_name(options::QUIET_NAME) - .short("q") + Arg::new(options::QUIET_NAME) + .short('q') .long("quiet") .visible_alias("silent") .help("never print headers giving file names") .overrides_with_all(&[options::VERBOSE_NAME, options::QUIET_NAME]), ) .arg( - Arg::with_name(options::VERBOSE_NAME) - .short("v") + Arg::new(options::VERBOSE_NAME) + .short('v') .long("verbose") .help("always print headers giving file names") .overrides_with_all(&[options::QUIET_NAME, options::VERBOSE_NAME]), ) .arg( - Arg::with_name(options::ZERO_NAME) - .short("z") + Arg::new(options::ZERO_NAME) + .short('z') .long("zero-terminated") .help("line delimiter is NUL, not newline") .overrides_with(options::ZERO_NAME), ) - .arg(Arg::with_name(options::FILES_NAME).multiple(true)) + .arg(Arg::new(options::FILES_NAME).multiple_occurrences(true)) } #[derive(PartialEq, Debug, Clone, Copy)] enum Modes { @@ -291,16 +291,95 @@ fn read_but_last_n_lines( Ok(()) } -fn head_backwards_file(input: &mut std::fs::File, options: &HeadOptions) -> std::io::Result<()> { - assert!(options.all_but_last); +/// Return the index in `input` just after the `n`th line from the end. +/// +/// If `n` exceeds the number of lines in this file, then return 0. +/// +/// The cursor must be at the start of the seekable input before +/// calling this function. This function rewinds the cursor to the +/// beginning of the input just before returning unless there is an +/// I/O error. +/// +/// If `zeroed` is `false`, interpret the newline character `b'\n'` as +/// a line ending. If `zeroed` is `true`, interpret the null character +/// `b'\0'` as a line ending instead. +/// +/// # Errors +/// +/// This function returns an error if there is a problem seeking +/// through or reading the input. +/// +/// # Examples +/// +/// The function returns the index of the byte immediately following +/// the line ending character of the `n`th line from the end of the +/// input: +/// +/// ```rust,ignore +/// let mut input = Cursor::new("x\ny\nz\n"); +/// assert_eq!(find_nth_line_from_end(&mut input, 0, false).unwrap(), 6); +/// assert_eq!(find_nth_line_from_end(&mut input, 1, false).unwrap(), 4); +/// assert_eq!(find_nth_line_from_end(&mut input, 2, false).unwrap(), 2); +/// ``` +/// +/// If `n` exceeds the number of lines in the file, always return 0: +/// +/// ```rust,ignore +/// let mut input = Cursor::new("x\ny\nz\n"); +/// assert_eq!(find_nth_line_from_end(&mut input, 3, false).unwrap(), 0); +/// assert_eq!(find_nth_line_from_end(&mut input, 4, false).unwrap(), 0); +/// assert_eq!(find_nth_line_from_end(&mut input, 1000, false).unwrap(), 0); +/// ``` +fn find_nth_line_from_end(input: &mut R, n: usize, zeroed: bool) -> std::io::Result +where + R: Read + Seek, +{ let size = input.seek(SeekFrom::End(0))?; let size = usize::try_from(size).unwrap(); + + let mut buffer = [0u8; BUF_SIZE]; + let buffer = &mut buffer[..BUF_SIZE.min(size)]; + let mut i = 0usize; + let mut lines = 0usize; + + loop { + // the casts here are ok, `buffer.len()` should never be above a few k + input.seek(SeekFrom::Current( + -((buffer.len() as i64).min((size - i) as i64)), + ))?; + input.read_exact(buffer)?; + for byte in buffer.iter().rev() { + match byte { + b'\n' if !zeroed => { + lines += 1; + } + 0u8 if zeroed => { + lines += 1; + } + _ => {} + } + // if it were just `n`, + if lines == n + 1 { + input.seek(SeekFrom::Start(0))?; + return Ok(size - i); + } + i += 1; + } + if size - i == 0 { + input.seek(SeekFrom::Start(0))?; + return Ok(0); + } + } +} + +fn head_backwards_file(input: &mut std::fs::File, options: &HeadOptions) -> std::io::Result<()> { + assert!(options.all_but_last); match options.mode { Modes::Bytes(n) => { + let size = input.metadata()?.len().try_into().unwrap(); if n >= size { return Ok(()); } else { - input.seek(SeekFrom::Start(0))?; read_n_bytes( &mut std::io::BufReader::with_capacity(BUF_SIZE, input), size - n, @@ -308,41 +387,10 @@ fn head_backwards_file(input: &mut std::fs::File, options: &HeadOptions) -> std: } } Modes::Lines(n) => { - let mut buffer = [0u8; BUF_SIZE]; - let buffer = &mut buffer[..BUF_SIZE.min(size)]; - let mut i = 0usize; - let mut lines = 0usize; - - let found = 'o: loop { - // the casts here are ok, `buffer.len()` should never be above a few k - input.seek(SeekFrom::Current( - -((buffer.len() as i64).min((size - i) as i64)), - ))?; - input.read_exact(buffer)?; - for byte in buffer.iter().rev() { - match byte { - b'\n' if !options.zeroed => { - lines += 1; - } - 0u8 if options.zeroed => { - lines += 1; - } - _ => {} - } - // if it were just `n`, - if lines == n + 1 { - break 'o i; - } - i += 1; - } - if size - i == 0 { - return Ok(()); - } - }; - input.seek(SeekFrom::Start(0))?; + let found = find_nth_line_from_end(input, n, options.zeroed)?; read_n_bytes( &mut std::io::BufReader::with_capacity(BUF_SIZE, input), - size - found, + found, )?; } } @@ -459,6 +507,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { #[cfg(test)] mod tests { use std::ffi::OsString; + use std::io::Cursor; use super::*; fn options(args: &str) -> Result { @@ -580,4 +629,15 @@ mod tests { assert!(read_n_bytes(&mut empty, 0).is_ok()); assert!(read_n_lines(&mut empty, 0, false).is_ok()); } + + #[test] + fn test_find_nth_line_from_end() { + let mut input = Cursor::new("x\ny\nz\n"); + assert_eq!(find_nth_line_from_end(&mut input, 0, false).unwrap(), 6); + assert_eq!(find_nth_line_from_end(&mut input, 1, false).unwrap(), 4); + assert_eq!(find_nth_line_from_end(&mut input, 2, false).unwrap(), 2); + assert_eq!(find_nth_line_from_end(&mut input, 3, false).unwrap(), 0); + assert_eq!(find_nth_line_from_end(&mut input, 4, false).unwrap(), 0); + assert_eq!(find_nth_line_from_end(&mut input, 1000, false).unwrap(), 0); + } } diff --git a/src/uu/hostid/Cargo.toml b/src/uu/hostid/Cargo.toml index 8cd57bdeb..99afcc075 100644 --- a/src/uu/hostid/Cargo.toml +++ b/src/uu/hostid/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_hostid" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "hostid ~ (uutils) display the numeric identifier of the current host" @@ -15,7 +15,7 @@ edition = "2018" path = "src/hostid.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/hostid/src/hostid.rs b/src/uu/hostid/src/hostid.rs index 309e15990..8ada55c12 100644 --- a/src/uu/hostid/src/hostid.rs +++ b/src/uu/hostid/src/hostid.rs @@ -25,10 +25,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) - .usage(SYNTAX) + .override_usage(SYNTAX) } fn hostid() { diff --git a/src/uu/hostname/Cargo.toml b/src/uu/hostname/Cargo.toml index 65edaf311..4402ae41b 100644 --- a/src/uu/hostname/Cargo.toml +++ b/src/uu/hostname/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_hostname" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "hostname ~ (uutils) display or set the host name of the current host" @@ -15,7 +15,7 @@ edition = "2018" path = "src/hostname.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" hostname = { version = "0.3", features = ["set"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["wide"] } diff --git a/src/uu/hostname/src/hostname.rs b/src/uu/hostname/src/hostname.rs index 9c8504027..94897b2c7 100644 --- a/src/uu/hostname/src/hostname.rs +++ b/src/uu/hostname/src/hostname.rs @@ -61,7 +61,7 @@ fn usage() -> String { #[uucore_procs::gen_uumain] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); - let matches = uu_app().usage(&usage[..]).get_matches_from(args); + let matches = uu_app().override_usage(&usage[..]).get_matches_from(args); #[cfg(windows)] let _handle = wsa::start().map_err_context(|| "failed to start Winsock".to_owned())?; @@ -72,39 +72,39 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(OPT_DOMAIN) - .short("d") + Arg::new(OPT_DOMAIN) + .short('d') .long("domain") .overrides_with_all(&[OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT]) .help("Display the name of the DNS domain if possible"), ) .arg( - Arg::with_name(OPT_IP_ADDRESS) - .short("i") + Arg::new(OPT_IP_ADDRESS) + .short('i') .long("ip-address") .overrides_with_all(&[OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT]) .help("Display the network address(es) of the host"), ) .arg( - Arg::with_name(OPT_FQDN) - .short("f") + Arg::new(OPT_FQDN) + .short('f') .long("fqdn") .overrides_with_all(&[OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT]) .help("Display the FQDN (Fully Qualified Domain Name) (default)"), ) .arg( - Arg::with_name(OPT_SHORT) - .short("s") + Arg::new(OPT_SHORT) + .short('s') .long("short") .overrides_with_all(&[OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT]) .help("Display the short hostname (the portion before the first dot) if possible"), ) - .arg(Arg::with_name(OPT_HOST)) + .arg(Arg::new(OPT_HOST).allow_invalid_utf8(true)) } fn display_hostname(matches: &ArgMatches) -> UResult<()> { diff --git a/src/uu/id/Cargo.toml b/src/uu/id/Cargo.toml index 6f673dad5..59c964fc2 100644 --- a/src/uu/id/Cargo.toml +++ b/src/uu/id/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_id" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "id ~ (uutils) display user and group information for USER" @@ -15,7 +15,7 @@ edition = "2018" path = "src/id.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "process"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } selinux = { version="0.2.1", optional = true } diff --git a/src/uu/id/src/id.rs b/src/uu/id/src/id.rs index efe9a5d4e..47b1ac1fd 100644 --- a/src/uu/id/src/id.rs +++ b/src/uu/id/src/id.rs @@ -132,7 +132,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let after_help = get_description(); let matches = uu_app() - .usage(&usage[..]) + .override_usage(&usage[..]) .after_help(&after_help[..]) .get_matches_from(args); @@ -347,13 +347,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(options::OPT_AUDIT) - .short("A") + Arg::new(options::OPT_AUDIT) + .short('A') .conflicts_with_all(&[ options::OPT_GROUP, options::OPT_EFFECTIVE_USER, @@ -368,22 +368,22 @@ pub fn uu_app() -> App<'static, 'static> { ), ) .arg( - Arg::with_name(options::OPT_EFFECTIVE_USER) - .short("u") + Arg::new(options::OPT_EFFECTIVE_USER) + .short('u') .long(options::OPT_EFFECTIVE_USER) .conflicts_with(options::OPT_GROUP) .help("Display only the effective user ID as a number."), ) .arg( - Arg::with_name(options::OPT_GROUP) - .short("g") + Arg::new(options::OPT_GROUP) + .short('g') .long(options::OPT_GROUP) .conflicts_with(options::OPT_EFFECTIVE_USER) .help("Display only the effective group ID as a number"), ) .arg( - Arg::with_name(options::OPT_GROUPS) - .short("G") + Arg::new(options::OPT_GROUPS) + .short('G') .long(options::OPT_GROUPS) .conflicts_with_all(&[ options::OPT_GROUP, @@ -399,13 +399,13 @@ pub fn uu_app() -> App<'static, 'static> { ), ) .arg( - Arg::with_name(options::OPT_HUMAN_READABLE) - .short("p") + Arg::new(options::OPT_HUMAN_READABLE) + .short('p') .help("Make the output human-readable. Each display is on a separate line."), ) .arg( - Arg::with_name(options::OPT_NAME) - .short("n") + Arg::new(options::OPT_NAME) + .short('n') .long(options::OPT_NAME) .help( "Display the name of the user or group ID for the -G, -g and -u options \ @@ -414,13 +414,13 @@ pub fn uu_app() -> App<'static, 'static> { ), ) .arg( - Arg::with_name(options::OPT_PASSWORD) - .short("P") + Arg::new(options::OPT_PASSWORD) + .short('P') .help("Display the id as a password file entry."), ) .arg( - Arg::with_name(options::OPT_REAL_ID) - .short("r") + Arg::new(options::OPT_REAL_ID) + .short('r') .long(options::OPT_REAL_ID) .help( "Display the real ID for the -G, -g and -u options instead of \ @@ -428,8 +428,8 @@ pub fn uu_app() -> App<'static, 'static> { ), ) .arg( - Arg::with_name(options::OPT_ZERO) - .short("z") + Arg::new(options::OPT_ZERO) + .short('z') .long(options::OPT_ZERO) .help( "delimit entries with NUL characters, not whitespace;\n\ @@ -437,15 +437,15 @@ pub fn uu_app() -> App<'static, 'static> { ), ) .arg( - Arg::with_name(options::OPT_CONTEXT) - .short("Z") + Arg::new(options::OPT_CONTEXT) + .short('Z') .long(options::OPT_CONTEXT) .conflicts_with_all(&[options::OPT_GROUP, options::OPT_EFFECTIVE_USER]) .help(CONTEXT_HELP_TEXT), ) .arg( - Arg::with_name(options::ARG_USERS) - .multiple(true) + Arg::new(options::ARG_USERS) + .multiple_occurrences(true) .takes_value(true) .value_name(options::ARG_USERS), ) diff --git a/src/uu/install/Cargo.toml b/src/uu/install/Cargo.toml index b756dbec8..d02d4a8b9 100644 --- a/src/uu/install/Cargo.toml +++ b/src/uu/install/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_install" -version = "0.0.9" +version = "0.0.12" authors = [ "Ben Eills ", "uutils developers", @@ -18,7 +18,7 @@ edition = "2018" path = "src/install.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } filetime = "0.2" file_diff = "1.0.0" libc = ">= 0.2" diff --git a/src/uu/install/src/install.rs b/src/uu/install/src/install.rs index a93add322..7f6727c38 100644 --- a/src/uu/install/src/install.rs +++ b/src/uu/install/src/install.rs @@ -175,7 +175,7 @@ fn usage() -> String { pub fn uumain(args: impl uucore::Args) -> UResult<()> { 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 paths: Vec = matches .values_of(ARG_FILES) @@ -192,7 +192,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) @@ -203,67 +203,67 @@ pub fn uu_app() -> App<'static, 'static> { backup_control::arguments::backup_no_args() ) .arg( - Arg::with_name(OPT_IGNORED) - .short("c") + Arg::new(OPT_IGNORED) + .short('c') .help("ignored") ) .arg( - Arg::with_name(OPT_COMPARE) - .short("C") + Arg::new(OPT_COMPARE) + .short('C') .long(OPT_COMPARE) .help("compare each pair of source and destination files, and in some cases, do not modify the destination at all") ) .arg( - Arg::with_name(OPT_DIRECTORY) - .short("d") + Arg::new(OPT_DIRECTORY) + .short('d') .long(OPT_DIRECTORY) .help("treat all arguments as directory names. create all components of the specified directories") ) .arg( // TODO implement flag - Arg::with_name(OPT_CREATE_LEADING) - .short("D") + Arg::new(OPT_CREATE_LEADING) + .short('D') .help("create all leading components of DEST except the last, then copy SOURCE to DEST") ) .arg( - Arg::with_name(OPT_GROUP) - .short("g") + Arg::new(OPT_GROUP) + .short('g') .long(OPT_GROUP) .help("set group ownership, instead of process's current group") .value_name("GROUP") .takes_value(true) ) .arg( - Arg::with_name(OPT_MODE) - .short("m") + Arg::new(OPT_MODE) + .short('m') .long(OPT_MODE) .help("set permission mode (as in chmod), instead of rwxr-xr-x") .value_name("MODE") .takes_value(true) ) .arg( - Arg::with_name(OPT_OWNER) - .short("o") + Arg::new(OPT_OWNER) + .short('o') .long(OPT_OWNER) .help("set ownership (super-user only)") .value_name("OWNER") .takes_value(true) ) .arg( - Arg::with_name(OPT_PRESERVE_TIMESTAMPS) - .short("p") + Arg::new(OPT_PRESERVE_TIMESTAMPS) + .short('p') .long(OPT_PRESERVE_TIMESTAMPS) .help("apply access/modification times of SOURCE files to corresponding destination files") ) .arg( - Arg::with_name(OPT_STRIP) - .short("s") + Arg::new(OPT_STRIP) + .short('s') .long(OPT_STRIP) .help("strip symbol tables (no action Windows)") ) .arg( - Arg::with_name(OPT_STRIP_PROGRAM) + Arg::new(OPT_STRIP_PROGRAM) .long(OPT_STRIP_PROGRAM) .help("program used to strip binaries (no action Windows)") .value_name("PROGRAM") @@ -273,42 +273,42 @@ pub fn uu_app() -> App<'static, 'static> { ) .arg( // TODO implement flag - Arg::with_name(OPT_TARGET_DIRECTORY) - .short("t") + Arg::new(OPT_TARGET_DIRECTORY) + .short('t') .long(OPT_TARGET_DIRECTORY) .help("move all SOURCE arguments into DIRECTORY") .value_name("DIRECTORY") ) .arg( // TODO implement flag - Arg::with_name(OPT_NO_TARGET_DIRECTORY) - .short("T") + Arg::new(OPT_NO_TARGET_DIRECTORY) + .short('T') .long(OPT_NO_TARGET_DIRECTORY) .help("(unimplemented) treat DEST as a normal file") ) .arg( - Arg::with_name(OPT_VERBOSE) - .short("v") + Arg::new(OPT_VERBOSE) + .short('v') .long(OPT_VERBOSE) .help("explain what is being done") ) .arg( // TODO implement flag - Arg::with_name(OPT_PRESERVE_CONTEXT) - .short("P") + Arg::new(OPT_PRESERVE_CONTEXT) + .short('P') .long(OPT_PRESERVE_CONTEXT) .help("(unimplemented) preserve security context") ) .arg( // TODO implement flag - Arg::with_name(OPT_CONTEXT) - .short("Z") + Arg::new(OPT_CONTEXT) + .short('Z') .long(OPT_CONTEXT) .help("(unimplemented) set security context of files and directories") .value_name("CONTEXT") ) - .arg(Arg::with_name(ARG_FILES).multiple(true).takes_value(true).min_values(1)) + .arg(Arg::new(ARG_FILES).multiple_occurrences(true).takes_value(true).min_values(1)) } /// Check for unimplemented command line arguments. diff --git a/src/uu/join/Cargo.toml b/src/uu/join/Cargo.toml index 73d9b4068..2f3b6d462 100644 --- a/src/uu/join/Cargo.toml +++ b/src/uu/join/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_join" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "join ~ (uutils) merge lines from inputs with matching join fields" @@ -15,7 +15,7 @@ edition = "2018" path = "src/join.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/join/src/join.rs b/src/uu/join/src/join.rs index a338a22c4..4729072d3 100644 --- a/src/uu/join/src/join.rs +++ b/src/uu/join/src/join.rs @@ -578,7 +578,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(NAME) .version(crate_version!()) .about( @@ -587,12 +587,10 @@ standard output. The default join field is the first, delimited by blanks. When FILE1 or FILE2 (not both) is -, read standard input.", ) - .help_message("display this help and exit") - .version_message("display version and exit") .arg( - Arg::with_name("a") - .short("a") - .multiple(true) + Arg::new("a") + .short('a') + .multiple_occurrences(true) .number_of_values(1) .possible_values(&["1", "2"]) .value_name("FILENUM") @@ -602,92 +600,92 @@ FILENUM is 1 or 2, corresponding to FILE1 or FILE2", ), ) .arg( - Arg::with_name("v") - .short("v") - .multiple(true) + Arg::new("v") + .short('v') + .multiple_occurrences(true) .number_of_values(1) .possible_values(&["1", "2"]) .value_name("FILENUM") .help("like -a FILENUM, but suppress joined output lines"), ) .arg( - Arg::with_name("e") - .short("e") + Arg::new("e") + .short('e') .takes_value(true) .value_name("EMPTY") .help("replace missing input fields with EMPTY"), ) .arg( - Arg::with_name("i") - .short("i") + Arg::new("i") + .short('i') .long("ignore-case") .help("ignore differences in case when comparing fields"), ) .arg( - Arg::with_name("j") - .short("j") + Arg::new("j") + .short('j') .takes_value(true) .value_name("FIELD") .help("equivalent to '-1 FIELD -2 FIELD'"), ) .arg( - Arg::with_name("o") - .short("o") + Arg::new("o") + .short('o') .takes_value(true) .value_name("FORMAT") .help("obey FORMAT while constructing output line"), ) .arg( - Arg::with_name("t") - .short("t") + Arg::new("t") + .short('t') .takes_value(true) .value_name("CHAR") .help("use CHAR as input and output field separator"), ) .arg( - Arg::with_name("1") - .short("1") + Arg::new("1") + .short('1') .takes_value(true) .value_name("FIELD") .help("join on this FIELD of file 1"), ) .arg( - Arg::with_name("2") - .short("2") + Arg::new("2") + .short('2') .takes_value(true) .value_name("FIELD") .help("join on this FIELD of file 2"), ) - .arg(Arg::with_name("check-order").long("check-order").help( + .arg(Arg::new("check-order").long("check-order").help( "check that the input is correctly sorted, \ even if all input lines are pairable", )) .arg( - Arg::with_name("nocheck-order") + Arg::new("nocheck-order") .long("nocheck-order") .help("do not check that the input is correctly sorted"), ) - .arg(Arg::with_name("header").long("header").help( + .arg(Arg::new("header").long("header").help( "treat the first line in each file as field headers, \ print them without trying to pair them", )) .arg( - Arg::with_name("z") - .short("z") + Arg::new("z") + .short('z') .long("zero-terminated") .help("line delimiter is NUL, not newline"), ) .arg( - Arg::with_name("file1") + Arg::new("file1") .required(true) .value_name("FILE1") - .hidden(true), + .hide(true), ) .arg( - Arg::with_name("file2") + Arg::new("file2") .required(true) .value_name("FILE2") - .hidden(true), + .hide(true), ) } diff --git a/src/uu/kill/Cargo.toml b/src/uu/kill/Cargo.toml index 6422cf7d6..400dbbc8f 100644 --- a/src/uu/kill/Cargo.toml +++ b/src/uu/kill/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_kill" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "kill ~ (uutils) send a signal to a process" @@ -15,7 +15,7 @@ edition = "2018" path = "src/kill.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["signals"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/kill/src/kill.rs b/src/uu/kill/src/kill.rs index e9b7ee349..a1a456c84 100644 --- a/src/uu/kill/src/kill.rs +++ b/src/uu/kill/src/kill.rs @@ -43,7 +43,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let obs_signal = handle_obsolete(&mut args); let usage = format!("{} [OPTIONS]... PID...", uucore::execution_phrase()); - let matches = uu_app().usage(&usage[..]).get_matches_from(args); + let matches = uu_app().override_usage(&usage[..]).get_matches_from(args); let mode = if matches.is_present(options::TABLE) || matches.is_present(options::TABLE_OLD) { Mode::Table @@ -78,36 +78,36 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(options::LIST) - .short("l") + Arg::new(options::LIST) + .short('l') .long(options::LIST) .help("Lists signals") .conflicts_with(options::TABLE) .conflicts_with(options::TABLE_OLD), ) .arg( - Arg::with_name(options::TABLE) - .short("t") + Arg::new(options::TABLE) + .short('t') .long(options::TABLE) .help("Lists table of signals"), ) - .arg(Arg::with_name(options::TABLE_OLD).short("L").hidden(true)) + .arg(Arg::new(options::TABLE_OLD).short('L').hide(true)) .arg( - Arg::with_name(options::SIGNAL) - .short("s") + Arg::new(options::SIGNAL) + .short('s') .long(options::SIGNAL) .help("Sends given signal") .takes_value(true), ) .arg( - Arg::with_name(options::PIDS_OR_SIGNALS) - .hidden(true) - .multiple(true), + Arg::new(options::PIDS_OR_SIGNALS) + .hide(true) + .multiple_occurrences(true), ) } diff --git a/src/uu/link/Cargo.toml b/src/uu/link/Cargo.toml index 7da8eb3ab..dc544e94e 100644 --- a/src/uu/link/Cargo.toml +++ b/src/uu/link/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_link" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "link ~ (uutils) create a hard (file system) link to FILE" @@ -16,9 +16,9 @@ path = "src/link.rs" [dependencies] libc = "0.2.42" +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } -clap = { version = "2.33", features = ["wrap_help"] } [[bin]] name = "link" diff --git a/src/uu/link/src/link.rs b/src/uu/link/src/link.rs index a54b71999..3a771aecf 100644 --- a/src/uu/link/src/link.rs +++ b/src/uu/link/src/link.rs @@ -23,7 +23,7 @@ fn usage() -> String { #[uucore_procs::gen_uumain] pub fn uumain(args: impl uucore::Args) -> UResult<()> { 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 files: Vec<_> = matches .values_of_os(options::FILES) @@ -36,16 +36,17 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { .map_err_context(|| format!("cannot create link {} to {}", new.quote(), old.quote())) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(options::FILES) - .hidden(true) + Arg::new(options::FILES) + .hide(true) .required(true) .min_values(2) .max_values(2) - .takes_value(true), + .takes_value(true) + .allow_invalid_utf8(true), ) } diff --git a/src/uu/ln/Cargo.toml b/src/uu/ln/Cargo.toml index 500f512e3..cfa19d6a3 100644 --- a/src/uu/ln/Cargo.toml +++ b/src/uu/ln/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_ln" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "ln ~ (uutils) create a (file system) link to TARGET" @@ -15,7 +15,7 @@ edition = "2018" path = "src/ln.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/ln/src/ln.rs b/src/uu/ln/src/ln.rs index 6d91f6fb7..d8036bbcf 100644 --- a/src/uu/ln/src/ln.rs +++ b/src/uu/ln/src/ln.rs @@ -135,7 +135,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let long_usage = long_usage(); let matches = uu_app() - .usage(&usage[..]) + .override_usage(&usage[..]) .after_help(&*format!( "{}\n{}", long_usage, @@ -179,30 +179,30 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { exec(&paths[..], &settings) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg(backup_control::arguments::backup()) .arg(backup_control::arguments::backup_no_args()) // TODO: opts.arg( - // Arg::with_name(("d", "directory", "allow users with appropriate privileges to attempt \ + // Arg::new(("d", "directory", "allow users with appropriate privileges to attempt \ // to make hard links to directories"); .arg( - Arg::with_name(options::FORCE) - .short("f") + Arg::new(options::FORCE) + .short('f') .long(options::FORCE) .help("remove existing destination files"), ) .arg( - Arg::with_name(options::INTERACTIVE) - .short("i") + Arg::new(options::INTERACTIVE) + .short('i') .long(options::INTERACTIVE) .help("prompt whether to remove existing destination files"), ) .arg( - Arg::with_name(options::NO_DEREFERENCE) - .short("n") + Arg::new(options::NO_DEREFERENCE) + .short('n') .long(options::NO_DEREFERENCE) .help( "treat LINK_NAME as a normal file if it is a \ @@ -210,13 +210,13 @@ pub fn uu_app() -> App<'static, 'static> { ), ) // TODO: opts.arg( - // Arg::with_name(("L", "logical", "dereference TARGETs that are symbolic links"); + // Arg::new(("L", "logical", "dereference TARGETs that are symbolic links"); // // TODO: opts.arg( - // Arg::with_name(("P", "physical", "make hard links directly to symbolic links"); + // Arg::new(("P", "physical", "make hard links directly to symbolic links"); .arg( - Arg::with_name(options::SYMBOLIC) - .short("s") + Arg::new(options::SYMBOLIC) + .short('s') .long("symbolic") .help("make symbolic links instead of hard links") // override added for https://github.com/uutils/coreutils/issues/2359 @@ -224,35 +224,35 @@ pub fn uu_app() -> App<'static, 'static> { ) .arg(backup_control::arguments::suffix()) .arg( - Arg::with_name(options::TARGET_DIRECTORY) - .short("t") + Arg::new(options::TARGET_DIRECTORY) + .short('t') .long(options::TARGET_DIRECTORY) .help("specify the DIRECTORY in which to create the links") .value_name("DIRECTORY") .conflicts_with(options::NO_TARGET_DIRECTORY), ) .arg( - Arg::with_name(options::NO_TARGET_DIRECTORY) - .short("T") + Arg::new(options::NO_TARGET_DIRECTORY) + .short('T') .long(options::NO_TARGET_DIRECTORY) .help("treat LINK_NAME as a normal file always"), ) .arg( - Arg::with_name(options::RELATIVE) - .short("r") + Arg::new(options::RELATIVE) + .short('r') .long(options::RELATIVE) .help("create symbolic links relative to link location") .requires(options::SYMBOLIC), ) .arg( - Arg::with_name(options::VERBOSE) - .short("v") + Arg::new(options::VERBOSE) + .short('v') .long(options::VERBOSE) .help("print name of each linked file"), ) .arg( - Arg::with_name(ARG_FILES) - .multiple(true) + Arg::new(ARG_FILES) + .multiple_occurrences(true) .takes_value(true) .required(true) .min_values(1), diff --git a/src/uu/logname/Cargo.toml b/src/uu/logname/Cargo.toml index b2dc33f40..67c24c257 100644 --- a/src/uu/logname/Cargo.toml +++ b/src/uu/logname/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_logname" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "logname ~ (uutils) display the login name of the current user" @@ -16,7 +16,7 @@ path = "src/logname.rs" [dependencies] libc = "0.2.42" -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/logname/src/logname.rs b/src/uu/logname/src/logname.rs index 927753932..860ac431c 100644 --- a/src/uu/logname/src/logname.rs +++ b/src/uu/logname/src/logname.rs @@ -45,7 +45,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { .collect_str(InvalidEncodingHandling::Ignore) .accept_any(); - let _ = uu_app().usage(usage()).get_matches_from(args); + let _ = uu_app().override_usage(usage()).get_matches_from(args); match get_userlogin() { Some(userlogin) => println!("{}", userlogin), @@ -55,7 +55,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(SUMMARY) diff --git a/src/uu/ls/Cargo.toml b/src/uu/ls/Cargo.toml index f22cc29c7..a9809d76e 100644 --- a/src/uu/ls/Cargo.toml +++ b/src/uu/ls/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_ls" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "ls ~ (uutils) display directory contents" @@ -16,7 +16,7 @@ path = "src/ls.rs" [dependencies] chrono = "0.4.19" -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo", "env"] } unicode-width = "0.1.8" number_prefix = "0.4" term_grid = "0.1.5" diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 4cacf3b8b..c645d8700 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -687,7 +687,7 @@ impl Config { pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); - let app = uu_app().usage(&usage[..]); + let app = uu_app().override_usage(&usage[..]); let matches = app.get_matches_from(args); @@ -701,7 +701,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { list(locs, config) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about( @@ -711,7 +711,7 @@ pub fn uu_app() -> App<'static, 'static> { ) // Format arguments .arg( - Arg::with_name(options::FORMAT) + Arg::new(options::FORMAT) .long(options::FORMAT) .help("Set the display format.") .takes_value(true) @@ -736,8 +736,8 @@ pub fn uu_app() -> App<'static, 'static> { ]), ) .arg( - Arg::with_name(options::format::COLUMNS) - .short(options::format::COLUMNS) + Arg::new(options::format::COLUMNS) + .short('C') .help("Display the files in columns.") .overrides_with_all(&[ options::FORMAT, @@ -748,8 +748,8 @@ pub fn uu_app() -> App<'static, 'static> { ]), ) .arg( - Arg::with_name(options::format::LONG) - .short("l") + Arg::new(options::format::LONG) + .short('l') .long(options::format::LONG) .help("Display detailed information.") .overrides_with_all(&[ @@ -761,8 +761,8 @@ pub fn uu_app() -> App<'static, 'static> { ]), ) .arg( - Arg::with_name(options::format::ACROSS) - .short(options::format::ACROSS) + Arg::new(options::format::ACROSS) + .short('x') .help("List entries in rows instead of in columns.") .overrides_with_all(&[ options::FORMAT, @@ -773,8 +773,8 @@ pub fn uu_app() -> App<'static, 'static> { ]), ) .arg( - Arg::with_name(options::format::COMMAS) - .short(options::format::COMMAS) + Arg::new(options::format::COMMAS) + .short('m') .help("List entries separated by commas.") .overrides_with_all(&[ options::FORMAT, @@ -791,36 +791,36 @@ pub fn uu_app() -> App<'static, 'static> { // ls -1g1 // even though `ls -11` and `ls -1 -g -1` work. .arg( - Arg::with_name(options::format::ONE_LINE) - .short(options::format::ONE_LINE) + Arg::new(options::format::ONE_LINE) + .short('1') .help("List one file per line.") - .multiple(true), + .multiple_occurrences(true), ) .arg( - Arg::with_name(options::format::LONG_NO_GROUP) - .short(options::format::LONG_NO_GROUP) + Arg::new(options::format::LONG_NO_GROUP) + .short('o') .help( "Long format without group information. \ Identical to --format=long with --no-group.", ) - .multiple(true), + .multiple_occurrences(true), ) .arg( - Arg::with_name(options::format::LONG_NO_OWNER) - .short(options::format::LONG_NO_OWNER) + Arg::new(options::format::LONG_NO_OWNER) + .short('g') .help("Long format without owner information.") - .multiple(true), + .multiple_occurrences(true), ) .arg( - Arg::with_name(options::format::LONG_NUMERIC_UID_GID) - .short("n") + Arg::new(options::format::LONG_NUMERIC_UID_GID) + .short('n') .long(options::format::LONG_NUMERIC_UID_GID) .help("-l with numeric UIDs and GIDs.") - .multiple(true), + .multiple_occurrences(true), ) // Quoting style .arg( - Arg::with_name(options::QUOTING_STYLE) + Arg::new(options::QUOTING_STYLE) .long(options::QUOTING_STYLE) .takes_value(true) .help("Set quoting style.") @@ -841,8 +841,8 @@ pub fn uu_app() -> App<'static, 'static> { ]), ) .arg( - Arg::with_name(options::quoting::LITERAL) - .short("N") + Arg::new(options::quoting::LITERAL) + .short('N') .long(options::quoting::LITERAL) .help("Use literal quoting style. Equivalent to `--quoting-style=literal`") .overrides_with_all(&[ @@ -853,8 +853,8 @@ pub fn uu_app() -> App<'static, 'static> { ]), ) .arg( - Arg::with_name(options::quoting::ESCAPE) - .short("b") + Arg::new(options::quoting::ESCAPE) + .short('b') .long(options::quoting::ESCAPE) .help("Use escape quoting style. Equivalent to `--quoting-style=escape`") .overrides_with_all(&[ @@ -865,8 +865,8 @@ pub fn uu_app() -> App<'static, 'static> { ]), ) .arg( - Arg::with_name(options::quoting::C) - .short("Q") + Arg::new(options::quoting::C) + .short('Q') .long(options::quoting::C) .help("Use C quoting style. Equivalent to `--quoting-style=c`") .overrides_with_all(&[ @@ -878,21 +878,21 @@ pub fn uu_app() -> App<'static, 'static> { ) // Control characters .arg( - Arg::with_name(options::HIDE_CONTROL_CHARS) - .short("q") + Arg::new(options::HIDE_CONTROL_CHARS) + .short('q') .long(options::HIDE_CONTROL_CHARS) .help("Replace control characters with '?' if they are not escaped.") .overrides_with_all(&[options::HIDE_CONTROL_CHARS, options::SHOW_CONTROL_CHARS]), ) .arg( - Arg::with_name(options::SHOW_CONTROL_CHARS) + Arg::new(options::SHOW_CONTROL_CHARS) .long(options::SHOW_CONTROL_CHARS) .help("Show control characters 'as is' if they are not escaped.") .overrides_with_all(&[options::HIDE_CONTROL_CHARS, options::SHOW_CONTROL_CHARS]), ) // Time arguments .arg( - Arg::with_name(options::TIME) + Arg::new(options::TIME) .long(options::TIME) .help( "Show time in :\n\ @@ -910,8 +910,8 @@ pub fn uu_app() -> App<'static, 'static> { .overrides_with_all(&[options::TIME, options::time::ACCESS, options::time::CHANGE]), ) .arg( - Arg::with_name(options::time::CHANGE) - .short(options::time::CHANGE) + Arg::new(options::time::CHANGE) + .short('c') .help( "If the long listing format (e.g., -l, -o) is being used, print the status \ change time (the 'ctime' in the inode) instead of the modification time. When \ @@ -921,8 +921,8 @@ pub fn uu_app() -> App<'static, 'static> { .overrides_with_all(&[options::TIME, options::time::ACCESS, options::time::CHANGE]), ) .arg( - Arg::with_name(options::time::ACCESS) - .short(options::time::ACCESS) + Arg::new(options::time::ACCESS) + .short('u') .help( "If the long listing format (e.g., -l, -o) is being used, print the status \ access time instead of the modification time. When explicitly sorting by time \ @@ -933,33 +933,33 @@ pub fn uu_app() -> App<'static, 'static> { ) // Hide and ignore .arg( - Arg::with_name(options::HIDE) + Arg::new(options::HIDE) .long(options::HIDE) .takes_value(true) - .multiple(true) + .multiple_occurrences(true) .value_name("PATTERN") .help( "do not list implied entries matching shell PATTERN (overridden by -a or -A)", ), ) .arg( - Arg::with_name(options::IGNORE) - .short("I") + Arg::new(options::IGNORE) + .short('I') .long(options::IGNORE) .takes_value(true) - .multiple(true) + .multiple_occurrences(true) .value_name("PATTERN") .help("do not list implied entries matching shell PATTERN"), ) .arg( - Arg::with_name(options::IGNORE_BACKUPS) - .short("B") + Arg::new(options::IGNORE_BACKUPS) + .short('B') .long(options::IGNORE_BACKUPS) .help("Ignore entries which end with ~."), ) // Sort arguments .arg( - Arg::with_name(options::SORT) + Arg::new(options::SORT) .long(options::SORT) .help("Sort by : name, none (-U), time (-t), size (-S) or extension (-X)") .value_name("field") @@ -976,8 +976,8 @@ pub fn uu_app() -> App<'static, 'static> { ]), ) .arg( - Arg::with_name(options::sort::SIZE) - .short(options::sort::SIZE) + Arg::new(options::sort::SIZE) + .short('S') .help("Sort by file size, largest first.") .overrides_with_all(&[ options::SORT, @@ -989,8 +989,8 @@ pub fn uu_app() -> App<'static, 'static> { ]), ) .arg( - Arg::with_name(options::sort::TIME) - .short(options::sort::TIME) + Arg::new(options::sort::TIME) + .short('t') .help("Sort by modification time (the 'mtime' in the inode), newest first.") .overrides_with_all(&[ options::SORT, @@ -1002,8 +1002,8 @@ pub fn uu_app() -> App<'static, 'static> { ]), ) .arg( - Arg::with_name(options::sort::VERSION) - .short(options::sort::VERSION) + Arg::new(options::sort::VERSION) + .short('v') .help("Natural sort of (version) numbers in the filenames.") .overrides_with_all(&[ options::SORT, @@ -1015,8 +1015,8 @@ pub fn uu_app() -> App<'static, 'static> { ]), ) .arg( - Arg::with_name(options::sort::EXTENSION) - .short(options::sort::EXTENSION) + Arg::new(options::sort::EXTENSION) + .short('X') .help("Sort alphabetically by entry extension.") .overrides_with_all(&[ options::SORT, @@ -1028,8 +1028,8 @@ pub fn uu_app() -> App<'static, 'static> { ]), ) .arg( - Arg::with_name(options::sort::NONE) - .short(options::sort::NONE) + Arg::new(options::sort::NONE) + .short('U') .help( "Do not sort; list the files in whatever order they are stored in the \ directory. This is especially useful when listing very large directories, \ @@ -1046,8 +1046,8 @@ pub fn uu_app() -> App<'static, 'static> { ) // Dereferencing .arg( - Arg::with_name(options::dereference::ALL) - .short("L") + Arg::new(options::dereference::ALL) + .short('L') .long(options::dereference::ALL) .help( "When showing file information for a symbolic link, show information for the \ @@ -1060,7 +1060,7 @@ pub fn uu_app() -> App<'static, 'static> { ]), ) .arg( - Arg::with_name(options::dereference::DIR_ARGS) + Arg::new(options::dereference::DIR_ARGS) .long(options::dereference::DIR_ARGS) .help( "Do not dereference symlinks except when they link to directories and are \ @@ -1073,8 +1073,8 @@ pub fn uu_app() -> App<'static, 'static> { ]), ) .arg( - Arg::with_name(options::dereference::ARGS) - .short("H") + Arg::new(options::dereference::ARGS) + .short('H') .long(options::dereference::ARGS) .help("Do not dereference symlinks except when given as command line arguments.") .overrides_with_all(&[ @@ -1085,25 +1085,25 @@ pub fn uu_app() -> App<'static, 'static> { ) // Long format options .arg( - Arg::with_name(options::NO_GROUP) + Arg::new(options::NO_GROUP) .long(options::NO_GROUP) - .short("-G") + .short('G') .help("Do not show group in long format."), ) - .arg(Arg::with_name(options::AUTHOR).long(options::AUTHOR).help( + .arg(Arg::new(options::AUTHOR).long(options::AUTHOR).help( "Show author in long format. \ On the supported platforms, the author always matches the file owner.", )) // Other Flags .arg( - Arg::with_name(options::files::ALL) - .short("a") + Arg::new(options::files::ALL) + .short('a') .long(options::files::ALL) .help("Do not ignore hidden files (files with names that start with '.')."), ) .arg( - Arg::with_name(options::files::ALMOST_ALL) - .short("A") + Arg::new(options::files::ALMOST_ALL) + .short('A') .long(options::files::ALMOST_ALL) .help( "In a directory, do not ignore all file names that start with '.', \ @@ -1111,8 +1111,8 @@ only ignore '.' and '..'.", ), ) .arg( - Arg::with_name(options::DIRECTORY) - .short("d") + Arg::new(options::DIRECTORY) + .short('d') .long(options::DIRECTORY) .help( "Only list the names of directories, rather than listing directory contents. \ @@ -1122,26 +1122,26 @@ only ignore '.' and '..'.", ), ) .arg( - Arg::with_name(options::size::HUMAN_READABLE) - .short("h") + Arg::new(options::size::HUMAN_READABLE) + .short('h') .long(options::size::HUMAN_READABLE) .help("Print human readable file sizes (e.g. 1K 234M 56G).") .overrides_with(options::size::SI), ) .arg( - Arg::with_name(options::size::SI) + Arg::new(options::size::SI) .long(options::size::SI) .help("Print human readable file sizes using powers of 1000 instead of 1024."), ) .arg( - Arg::with_name(options::INODE) - .short("i") + Arg::new(options::INODE) + .short('i') .long(options::INODE) .help("print the index number of each file"), ) .arg( - Arg::with_name(options::REVERSE) - .short("r") + Arg::new(options::REVERSE) + .short('r') .long(options::REVERSE) .help( "Reverse whatever the sorting method is e.g., list files in reverse \ @@ -1149,21 +1149,21 @@ only ignore '.' and '..'.", ), ) .arg( - Arg::with_name(options::RECURSIVE) - .short("R") + Arg::new(options::RECURSIVE) + .short('R') .long(options::RECURSIVE) .help("List the contents of all directories recursively."), ) .arg( - Arg::with_name(options::WIDTH) + Arg::new(options::WIDTH) .long(options::WIDTH) - .short("w") + .short('w') .help("Assume that the terminal is COLS columns wide.") .value_name("COLS") .takes_value(true), ) .arg( - Arg::with_name(options::COLOR) + Arg::new(options::COLOR) .long(options::COLOR) .help("Color output based on file type.") .takes_value(true) @@ -1174,7 +1174,7 @@ only ignore '.' and '..'.", .min_values(0), ) .arg( - Arg::with_name(options::INDICATOR_STYLE) + Arg::new(options::INDICATOR_STYLE) .long(options::INDICATOR_STYLE) .help( "Append indicator with style WORD to entry names: \ @@ -1190,8 +1190,8 @@ only ignore '.' and '..'.", ]), ) .arg( - Arg::with_name(options::indicator_style::CLASSIFY) - .short("F") + Arg::new(options::indicator_style::CLASSIFY) + .short('F') .long(options::indicator_style::CLASSIFY) .help( "Append a character to each file name indicating the file type. Also, for \ @@ -1207,7 +1207,7 @@ only ignore '.' and '..'.", ]), ) .arg( - Arg::with_name(options::indicator_style::FILE_TYPE) + Arg::new(options::indicator_style::FILE_TYPE) .long(options::indicator_style::FILE_TYPE) .help("Same as --classify, but do not append '*'") .overrides_with_all(&[ @@ -1218,8 +1218,8 @@ only ignore '.' and '..'.", ]), ) .arg( - Arg::with_name(options::indicator_style::SLASH) - .short(options::indicator_style::SLASH) + Arg::new(options::indicator_style::SLASH) + .short('p') .help("Append / indicator to directories.") .overrides_with_all(&[ options::indicator_style::FILE_TYPE, @@ -1230,7 +1230,7 @@ only ignore '.' and '..'.", ) .arg( //This still needs support for posix-*, +FORMAT - Arg::with_name(options::TIME_STYLE) + Arg::new(options::TIME_STYLE) .long(options::TIME_STYLE) .help("time/date format with -l; see TIME_STYLE below") .value_name("TIME_STYLE") @@ -1239,22 +1239,23 @@ only ignore '.' and '..'.", .overrides_with_all(&[options::TIME_STYLE]), ) .arg( - Arg::with_name(options::FULL_TIME) + Arg::new(options::FULL_TIME) .long(options::FULL_TIME) .overrides_with(options::FULL_TIME) .help("like -l --time-style=full-iso"), ) .arg( - Arg::with_name(options::CONTEXT) - .short("Z") + Arg::new(options::CONTEXT) + .short('Z') .long(options::CONTEXT) .help(CONTEXT_HELP_TEXT), ) // Positional arguments .arg( - Arg::with_name(options::PATHS) - .multiple(true) - .takes_value(true), + Arg::new(options::PATHS) + .multiple_occurrences(true) + .takes_value(true) + .allow_invalid_utf8(true), ) .after_help( "The TIME_STYLE argument can be full-iso, long-iso, iso. \ diff --git a/src/uu/mkdir/Cargo.toml b/src/uu/mkdir/Cargo.toml index 3bf723e8f..519aa9113 100644 --- a/src/uu/mkdir/Cargo.toml +++ b/src/uu/mkdir/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_mkdir" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "mkdir ~ (uutils) create DIRECTORY" @@ -15,7 +15,7 @@ edition = "2018" path = "src/mkdir.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs", "mode"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/mkdir/src/mkdir.rs b/src/uu/mkdir/src/mkdir.rs index 9ff816dcb..883975c28 100644 --- a/src/uu/mkdir/src/mkdir.rs +++ b/src/uu/mkdir/src/mkdir.rs @@ -96,7 +96,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { // opts.optflag("Z", "context", "set SELinux security context" + // " of each created directory to CTX"), let matches = uu_app() - .usage(&usage[..]) + .override_usage(&usage[..]) .after_help(&after_help[..]) .get_matches_from(args); @@ -110,35 +110,36 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(options::MODE) - .short("m") + Arg::new(options::MODE) + .short('m') .long(options::MODE) .help("set file mode (not implemented on windows)") .default_value("755"), ) .arg( - Arg::with_name(options::PARENTS) - .short("p") + Arg::new(options::PARENTS) + .short('p') .long(options::PARENTS) .alias("parent") .help("make parent directories as needed"), ) .arg( - Arg::with_name(options::VERBOSE) - .short("v") + Arg::new(options::VERBOSE) + .short('v') .long(options::VERBOSE) .help("print a message for each printed directory"), ) .arg( - Arg::with_name(options::DIRS) - .multiple(true) + Arg::new(options::DIRS) + .multiple_occurrences(true) .takes_value(true) - .min_values(1), + .min_values(1) + .allow_invalid_utf8(true), ) } diff --git a/src/uu/mkfifo/Cargo.toml b/src/uu/mkfifo/Cargo.toml index e1e668e63..971b20f45 100644 --- a/src/uu/mkfifo/Cargo.toml +++ b/src/uu/mkfifo/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_mkfifo" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "mkfifo ~ (uutils) create FIFOs (named pipes)" @@ -15,7 +15,7 @@ edition = "2018" path = "src/mkfifo.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/mkfifo/src/mkfifo.rs b/src/uu/mkfifo/src/mkfifo.rs index dfb595a72..120c9177b 100644 --- a/src/uu/mkfifo/src/mkfifo.rs +++ b/src/uu/mkfifo/src/mkfifo.rs @@ -69,27 +69,27 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .name(NAME) .version(crate_version!()) - .usage(USAGE) + .override_usage(USAGE) .about(SUMMARY) .arg( - Arg::with_name(options::MODE) - .short("m") + Arg::new(options::MODE) + .short('m') .long(options::MODE) .help("file permissions for the fifo") .default_value("0666") .value_name("0666"), ) .arg( - Arg::with_name(options::SE_LINUX_SECURITY_CONTEXT) - .short(options::SE_LINUX_SECURITY_CONTEXT) + Arg::new(options::SE_LINUX_SECURITY_CONTEXT) + .short('Z') .help("set the SELinux security context to default type"), ) .arg( - Arg::with_name(options::CONTEXT) + Arg::new(options::CONTEXT) .long(options::CONTEXT) .value_name("CTX") .help( @@ -97,5 +97,9 @@ pub fn uu_app() -> App<'static, 'static> { or SMACK security context to CTX", ), ) - .arg(Arg::with_name(options::FIFO).hidden(true).multiple(true)) + .arg( + Arg::new(options::FIFO) + .hide(true) + .multiple_occurrences(true), + ) } diff --git a/src/uu/mknod/Cargo.toml b/src/uu/mknod/Cargo.toml index c4824a7a6..ab03a08e8 100644 --- a/src/uu/mknod/Cargo.toml +++ b/src/uu/mknod/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_mknod" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "mknod ~ (uutils) create special file NAME of TYPE" @@ -16,7 +16,7 @@ name = "uu_mknod" path = "src/mknod.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "^0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["mode"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/mknod/src/mknod.rs b/src/uu/mknod/src/mknod.rs index b93716a63..bee4bade2 100644 --- a/src/uu/mknod/src/mknod.rs +++ b/src/uu/mknod/src/mknod.rs @@ -143,28 +143,28 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) - .usage(USAGE) + .override_usage(USAGE) .after_help(LONG_HELP) .about(ABOUT) .arg( - Arg::with_name("mode") - .short("m") + Arg::new("mode") + .short('m') .long("mode") .value_name("MODE") .help("set file permission bits to MODE, not a=rw - umask"), ) .arg( - Arg::with_name("name") + Arg::new("name") .value_name("NAME") .help("name of the new file") .required(true) .index(1), ) .arg( - Arg::with_name("type") + Arg::new("type") .value_name("TYPE") .help("type of the new file (b, c, u or p)") .required(true) @@ -172,14 +172,14 @@ pub fn uu_app() -> App<'static, 'static> { .index(2), ) .arg( - Arg::with_name("major") + Arg::new("major") .value_name("MAJOR") .help("major file type") .validator(valid_u64) .index(3), ) .arg( - Arg::with_name("minor") + Arg::new("minor") .value_name("MINOR") .help("minor file type") .validator(valid_u64) @@ -202,7 +202,7 @@ fn get_mode(matches: &ArgMatches) -> Result { } } -fn valid_type(tpe: String) -> Result<(), String> { +fn valid_type(tpe: &str) -> Result<(), String> { // Only check the first character, to allow mnemonic usage like // 'mknod /dev/rst0 character 18 0'. tpe.chars() @@ -217,6 +217,6 @@ fn valid_type(tpe: String) -> Result<(), String> { }) } -fn valid_u64(num: String) -> Result<(), String> { - num.parse::().map(|_| ()).map_err(|_| num) +fn valid_u64(num: &str) -> Result<(), String> { + num.parse::().map(|_| ()).map_err(|_| num.into()) } diff --git a/src/uu/mktemp/Cargo.toml b/src/uu/mktemp/Cargo.toml index 91eed0855..c183b14a9 100644 --- a/src/uu/mktemp/Cargo.toml +++ b/src/uu/mktemp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_mktemp" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "mktemp ~ (uutils) create and display a temporary file or directory from TEMPLATE" @@ -15,7 +15,7 @@ edition = "2018" path = "src/mktemp.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } rand = "0.5" tempfile = "3.1" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/mktemp/src/mktemp.rs b/src/uu/mktemp/src/mktemp.rs index 4318f0ad6..30c7b6375 100644 --- a/src/uu/mktemp/src/mktemp.rs +++ b/src/uu/mktemp/src/mktemp.rs @@ -78,7 +78,7 @@ impl Display for MkTempError { pub fn uumain(args: impl uucore::Args) -> UResult<()> { 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 template = matches.value_of(ARG_TEMPLATE).unwrap(); let tmpdir = matches.value_of(OPT_TMPDIR).unwrap_or_default(); @@ -135,30 +135,30 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(OPT_DIRECTORY) - .short("d") + Arg::new(OPT_DIRECTORY) + .short('d') .long(OPT_DIRECTORY) .help("Make a directory instead of a file"), ) .arg( - Arg::with_name(OPT_DRY_RUN) - .short("u") + Arg::new(OPT_DRY_RUN) + .short('u') .long(OPT_DRY_RUN) .help("do not create anything; merely print a name (unsafe)"), ) .arg( - Arg::with_name(OPT_QUIET) - .short("q") + Arg::new(OPT_QUIET) + .short('q') .long("quiet") .help("Fail silently if an error occurs."), ) .arg( - Arg::with_name(OPT_SUFFIX) + Arg::new(OPT_SUFFIX) .long(OPT_SUFFIX) .help( "append SUFFIX to TEMPLATE; SUFFIX must not contain a path separator. \ @@ -167,8 +167,8 @@ pub fn uu_app() -> App<'static, 'static> { .value_name("SUFFIX"), ) .arg( - Arg::with_name(OPT_TMPDIR) - .short("p") + Arg::new(OPT_TMPDIR) + .short('p') .long(OPT_TMPDIR) .help( "interpret TEMPLATE relative to DIR; if DIR is not specified, use \ @@ -178,13 +178,13 @@ pub fn uu_app() -> App<'static, 'static> { ) .value_name("DIR"), ) - .arg(Arg::with_name(OPT_T).short(OPT_T).help( + .arg(Arg::new(OPT_T).short('t').help( "Generate a template (using the supplied prefix and TMPDIR (TMP on windows) if set) \ to create a filename template [deprecated]", )) .arg( - Arg::with_name(ARG_TEMPLATE) - .multiple(false) + Arg::new(ARG_TEMPLATE) + .multiple_occurrences(false) .takes_value(true) .max_values(1) .default_value(DEFAULT_TEMPLATE), diff --git a/src/uu/more/Cargo.toml b/src/uu/more/Cargo.toml index cc3ab162a..068443906 100644 --- a/src/uu/more/Cargo.toml +++ b/src/uu/more/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_more" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "more ~ (uutils) input perusal filter" @@ -15,7 +15,7 @@ edition = "2018" path = "src/more.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version = ">=0.0.7", package = "uucore", path = "../../uucore" } uucore_procs = { version=">=0.0.8", package = "uucore_procs", path = "../../uucore_procs" } crossterm = ">=0.19" diff --git a/src/uu/more/src/more.rs b/src/uu/more/src/more.rs index dc5acbff8..fecf032a3 100644 --- a/src/uu/more/src/more.rs +++ b/src/uu/more/src/more.rs @@ -96,64 +96,64 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .about("A file perusal filter for CRT viewing.") .version(crate_version!()) .arg( - Arg::with_name(options::SILENT) - .short("d") + Arg::new(options::SILENT) + .short('d') .long(options::SILENT) .help("Display help instead of ringing bell"), ) // The commented arguments below are unimplemented: /* .arg( - Arg::with_name(options::LOGICAL) - .short("f") + Arg::new(options::LOGICAL) + .short('f') .long(options::LOGICAL) .help("Count logical rather than screen lines"), ) .arg( - Arg::with_name(options::NO_PAUSE) - .short("l") + Arg::new(options::NO_PAUSE) + .short('l') .long(options::NO_PAUSE) .help("Suppress pause after form feed"), ) .arg( - Arg::with_name(options::PRINT_OVER) - .short("c") + Arg::new(options::PRINT_OVER) + .short('c') .long(options::PRINT_OVER) .help("Do not scroll, display text and clean line ends"), ) .arg( - Arg::with_name(options::CLEAN_PRINT) - .short("p") + Arg::new(options::CLEAN_PRINT) + .short('p') .long(options::CLEAN_PRINT) .help("Do not scroll, clean screen and display text"), ) .arg( - Arg::with_name(options::SQUEEZE) - .short("s") + Arg::new(options::SQUEEZE) + .short('s') .long(options::SQUEEZE) .help("Squeeze multiple blank lines into one"), ) .arg( - Arg::with_name(options::PLAIN) - .short("u") + Arg::new(options::PLAIN) + .short('u') .long(options::PLAIN) .help("Suppress underlining and bold"), ) .arg( - Arg::with_name(options::LINES) - .short("n") + Arg::new(options::LINES) + .short('n') .long(options::LINES) .value_name("number") .takes_value(true) .help("The number of lines per screen full"), ) .arg( - Arg::with_name(options::NUMBER) + Arg::new(options::NUMBER) .allow_hyphen_values(true) .long(options::NUMBER) .required(false) @@ -161,8 +161,8 @@ pub fn uu_app() -> App<'static, 'static> { .help("Same as --lines"), ) .arg( - Arg::with_name(options::FROM_LINE) - .short("F") + Arg::new(options::FROM_LINE) + .short('F') .allow_hyphen_values(true) .required(false) .takes_value(true) @@ -170,8 +170,8 @@ pub fn uu_app() -> App<'static, 'static> { .help("Display file beginning from line number"), ) .arg( - Arg::with_name(options::PATTERN) - .short("P") + Arg::new(options::PATTERN) + .short('P') .allow_hyphen_values(true) .required(false) .takes_value(true) @@ -179,9 +179,9 @@ pub fn uu_app() -> App<'static, 'static> { ) */ .arg( - Arg::with_name(options::FILES) + Arg::new(options::FILES) .required(false) - .multiple(true) + .multiple_occurrences(true) .help("Path to the files to be read"), ) } diff --git a/src/uu/mv/Cargo.toml b/src/uu/mv/Cargo.toml index 2eaad7016..dd43819bf 100644 --- a/src/uu/mv/Cargo.toml +++ b/src/uu/mv/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_mv" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "mv ~ (uutils) move (rename) SOURCE to DESTINATION" @@ -15,7 +15,7 @@ edition = "2018" path = "src/mv.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } fs_extra = "1.1.0" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index 6f0fa03e8..bf2d03ba3 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -82,7 +82,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { LONG_HELP, backup_control::BACKUP_CONTROL_LONG_HELP )) - .usage(&usage[..]) + .override_usage(&usage[..]) .get_matches_from(args); let files: Vec = matches @@ -119,7 +119,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { exec(&files[..], behavior) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) @@ -130,24 +130,24 @@ pub fn uu_app() -> App<'static, 'static> { backup_control::arguments::backup_no_args() ) .arg( - Arg::with_name(OPT_FORCE) - .short("f") + Arg::new(OPT_FORCE) + .short('f') .long(OPT_FORCE) .help("do not prompt before overwriting") ) .arg( - Arg::with_name(OPT_INTERACTIVE) - .short("i") + Arg::new(OPT_INTERACTIVE) + .short('i') .long(OPT_INTERACTIVE) .help("prompt before override") ) .arg( - Arg::with_name(OPT_NO_CLOBBER).short("n") + Arg::new(OPT_NO_CLOBBER).short('n') .long(OPT_NO_CLOBBER) .help("do not overwrite an existing file") ) .arg( - Arg::with_name(OPT_STRIP_TRAILING_SLASHES) + Arg::new(OPT_STRIP_TRAILING_SLASHES) .long(OPT_STRIP_TRAILING_SLASHES) .help("remove any trailing slashes from each SOURCE argument") ) @@ -155,37 +155,39 @@ pub fn uu_app() -> App<'static, 'static> { backup_control::arguments::suffix() ) .arg( - Arg::with_name(OPT_TARGET_DIRECTORY) - .short("t") + Arg::new(OPT_TARGET_DIRECTORY) + .short('t') .long(OPT_TARGET_DIRECTORY) .help("move all SOURCE arguments into DIRECTORY") .takes_value(true) .value_name("DIRECTORY") .conflicts_with(OPT_NO_TARGET_DIRECTORY) + .allow_invalid_utf8(true) ) .arg( - Arg::with_name(OPT_NO_TARGET_DIRECTORY) - .short("T") + Arg::new(OPT_NO_TARGET_DIRECTORY) + .short('T') .long(OPT_NO_TARGET_DIRECTORY). help("treat DEST as a normal file") ) .arg( - Arg::with_name(OPT_UPDATE) - .short("u") + Arg::new(OPT_UPDATE) + .short('u') .long(OPT_UPDATE) .help("move only when the SOURCE file is newer than the destination file or when the destination file is missing") ) .arg( - Arg::with_name(OPT_VERBOSE) - .short("v") + Arg::new(OPT_VERBOSE) + .short('v') .long(OPT_VERBOSE).help("explain what is being done") ) .arg( - Arg::with_name(ARG_FILES) - .multiple(true) + Arg::new(ARG_FILES) + .multiple_occurrences(true) .takes_value(true) .min_values(2) .required(true) + .allow_invalid_utf8(true) ) } diff --git a/src/uu/nice/Cargo.toml b/src/uu/nice/Cargo.toml index 38540cb98..6b72b35f3 100644 --- a/src/uu/nice/Cargo.toml +++ b/src/uu/nice/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_nice" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "nice ~ (uutils) run PROGRAM with modified scheduling priority" @@ -15,7 +15,7 @@ edition = "2018" path = "src/nice.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" nix = "0.23.1" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/nice/src/nice.rs b/src/uu/nice/src/nice.rs index dbbb0d7e6..a2aea26b0 100644 --- a/src/uu/nice/src/nice.rs +++ b/src/uu/nice/src/nice.rs @@ -40,7 +40,7 @@ process).", pub fn uumain(args: impl uucore::Args) -> UResult<()> { 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 mut niceness = unsafe { nix::errno::Errno::clear(); @@ -107,17 +107,17 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .setting(AppSettings::TrailingVarArg) .version(crate_version!()) .arg( - Arg::with_name(options::ADJUSTMENT) - .short("n") + Arg::new(options::ADJUSTMENT) + .short('n') .long(options::ADJUSTMENT) .help("add N to the niceness (default is 10)") .takes_value(true) .allow_hyphen_values(true), ) - .arg(Arg::with_name(options::COMMAND).multiple(true)) + .arg(Arg::new(options::COMMAND).multiple_occurrences(true)) } diff --git a/src/uu/nl/Cargo.toml b/src/uu/nl/Cargo.toml index 2fc09d192..e6861c804 100644 --- a/src/uu/nl/Cargo.toml +++ b/src/uu/nl/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_nl" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "nl ~ (uutils) display input with added line numbers" @@ -15,7 +15,7 @@ edition = "2018" path = "src/nl.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } aho-corasick = "0.7.3" libc = "0.2.42" memchr = "2.2.0" diff --git a/src/uu/nl/src/nl.rs b/src/uu/nl/src/nl.rs index b004d2b74..1b7910629 100644 --- a/src/uu/nl/src/nl.rs +++ b/src/uu/nl/src/nl.rs @@ -140,84 +140,88 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .name(NAME) .version(crate_version!()) - .usage(USAGE) - .arg(Arg::with_name(options::FILE).hidden(true).multiple(true)) + .override_usage(USAGE) .arg( - Arg::with_name(options::BODY_NUMBERING) - .short("b") + Arg::new(options::FILE) + .hide(true) + .multiple_occurrences(true), + ) + .arg( + Arg::new(options::BODY_NUMBERING) + .short('b') .long(options::BODY_NUMBERING) .help("use STYLE for numbering body lines") .value_name("SYNTAX"), ) .arg( - Arg::with_name(options::SECTION_DELIMITER) - .short("d") + Arg::new(options::SECTION_DELIMITER) + .short('d') .long(options::SECTION_DELIMITER) .help("use CC for separating logical pages") .value_name("CC"), ) .arg( - Arg::with_name(options::FOOTER_NUMBERING) - .short("f") + Arg::new(options::FOOTER_NUMBERING) + .short('f') .long(options::FOOTER_NUMBERING) .help("use STYLE for numbering footer lines") .value_name("STYLE"), ) .arg( - Arg::with_name(options::HEADER_NUMBERING) - .short("h") + Arg::new(options::HEADER_NUMBERING) + .short('h') .long(options::HEADER_NUMBERING) .help("use STYLE for numbering header lines") .value_name("STYLE"), ) .arg( - Arg::with_name(options::LINE_INCREMENT) - .short("i") + Arg::new(options::LINE_INCREMENT) + .short('i') .long(options::LINE_INCREMENT) .help("line number increment at each line") .value_name("NUMBER"), ) .arg( - Arg::with_name(options::JOIN_BLANK_LINES) - .short("l") + Arg::new(options::JOIN_BLANK_LINES) + .short('l') .long(options::JOIN_BLANK_LINES) .help("group of NUMBER empty lines counted as one") .value_name("NUMBER"), ) .arg( - Arg::with_name(options::NUMBER_FORMAT) - .short("n") + Arg::new(options::NUMBER_FORMAT) + .short('n') .long(options::NUMBER_FORMAT) .help("insert line numbers according to FORMAT") .value_name("FORMAT"), ) .arg( - Arg::with_name(options::NO_RENUMBER) - .short("p") + Arg::new(options::NO_RENUMBER) + .short('p') .long(options::NO_RENUMBER) .help("do not reset line numbers at logical pages"), ) .arg( - Arg::with_name(options::NUMBER_SEPARATOR) - .short("s") + Arg::new(options::NUMBER_SEPARATOR) + .short('s') .long(options::NUMBER_SEPARATOR) .help("add STRING after (possible) line number") .value_name("STRING"), ) .arg( - Arg::with_name(options::STARTING_LINE_NUMBER) - .short("v") + Arg::new(options::STARTING_LINE_NUMBER) + .short('v') .long(options::STARTING_LINE_NUMBER) .help("first line number on each logical page") .value_name("NUMBER"), ) .arg( - Arg::with_name(options::NUMBER_WIDTH) - .short("w") + Arg::new(options::NUMBER_WIDTH) + .short('w') .long(options::NUMBER_WIDTH) .help("use NUMBER columns for line numbers") .value_name("NUMBER"), diff --git a/src/uu/nohup/Cargo.toml b/src/uu/nohup/Cargo.toml index 7e38a25a0..a735f72db 100644 --- a/src/uu/nohup/Cargo.toml +++ b/src/uu/nohup/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_nohup" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "nohup ~ (uutils) run COMMAND, ignoring hangup signals" @@ -15,7 +15,7 @@ edition = "2018" path = "src/nohup.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" atty = "0.2" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } diff --git a/src/uu/nohup/src/nohup.rs b/src/uu/nohup/src/nohup.rs index 505911b3e..a0305474b 100644 --- a/src/uu/nohup/src/nohup.rs +++ b/src/uu/nohup/src/nohup.rs @@ -88,7 +88,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { .collect_str(InvalidEncodingHandling::ConvertLossy) .accept_any(); - let matches = uu_app().usage(&usage[..]).get_matches_from(args); + let matches = uu_app().override_usage(&usage[..]).get_matches_from(args); replace_fds()?; @@ -114,16 +114,16 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .after_help(LONG_HELP) .arg( - Arg::with_name(options::CMD) - .hidden(true) + Arg::new(options::CMD) + .hide(true) .required(true) - .multiple(true), + .multiple_occurrences(true), ) .setting(AppSettings::TrailingVarArg) } diff --git a/src/uu/nproc/Cargo.toml b/src/uu/nproc/Cargo.toml index 7bba0a5fd..608994bf7 100644 --- a/src/uu/nproc/Cargo.toml +++ b/src/uu/nproc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_nproc" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "nproc ~ (uutils) display the number of processing units available" @@ -17,7 +17,7 @@ path = "src/nproc.rs" [dependencies] libc = "0.2.42" num_cpus = "1.10" -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/nproc/src/nproc.rs b/src/uu/nproc/src/nproc.rs index 4ab1378b0..583cb003b 100644 --- a/src/uu/nproc/src/nproc.rs +++ b/src/uu/nproc/src/nproc.rs @@ -33,7 +33,7 @@ fn usage() -> String { #[uucore_procs::gen_uumain] pub fn uumain(args: impl uucore::Args) -> UResult<()> { 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 mut ignore = match matches.value_of(OPT_IGNORE) { Some(numstr) => match numstr.parse() { @@ -71,19 +71,17 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(OPT_ALL) - .short("") + Arg::new(OPT_ALL) .long(OPT_ALL) .help("print the number of cores available to the system"), ) .arg( - Arg::with_name(OPT_IGNORE) - .short("") + Arg::new(OPT_IGNORE) .long(OPT_IGNORE) .takes_value(true) .help("ignore up to N cores"), diff --git a/src/uu/numfmt/Cargo.toml b/src/uu/numfmt/Cargo.toml index 14ddbef8f..b4954884d 100644 --- a/src/uu/numfmt/Cargo.toml +++ b/src/uu/numfmt/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_numfmt" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "numfmt ~ (uutils) reformat NUMBER" @@ -15,7 +15,7 @@ edition = "2018" path = "src/numfmt.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/numfmt/src/numfmt.rs b/src/uu/numfmt/src/numfmt.rs index b84b9ab1b..29f1914d5 100644 --- a/src/uu/numfmt/src/numfmt.rs +++ b/src/uu/numfmt/src/numfmt.rs @@ -159,7 +159,7 @@ fn parse_options(args: &ArgMatches) -> Result { pub fn uumain(args: impl uucore::Args) -> UResult<()> { 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 result = parse_options(&matches).and_then(|options| match matches.values_of(options::NUMBER) { @@ -178,42 +178,42 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .after_help(LONG_HELP) .setting(AppSettings::AllowNegativeNumbers) .arg( - Arg::with_name(options::DELIMITER) - .short("d") + Arg::new(options::DELIMITER) + .short('d') .long(options::DELIMITER) .value_name("X") .help("use X instead of whitespace for field delimiter"), ) .arg( - Arg::with_name(options::FIELD) + Arg::new(options::FIELD) .long(options::FIELD) .help("replace the numbers in these input fields (default=1) see FIELDS below") .value_name("FIELDS") .default_value(options::FIELD_DEFAULT), ) .arg( - Arg::with_name(options::FROM) + Arg::new(options::FROM) .long(options::FROM) .help("auto-scale input numbers to UNITs; see UNIT below") .value_name("UNIT") .default_value(options::FROM_DEFAULT), ) .arg( - Arg::with_name(options::TO) + Arg::new(options::TO) .long(options::TO) .help("auto-scale output numbers to UNITs; see UNIT below") .value_name("UNIT") .default_value(options::TO_DEFAULT), ) .arg( - Arg::with_name(options::PADDING) + Arg::new(options::PADDING) .long(options::PADDING) .help( "pad the output to N characters; positive N will \ @@ -224,18 +224,18 @@ pub fn uu_app() -> App<'static, 'static> { .value_name("N"), ) .arg( - Arg::with_name(options::HEADER) + Arg::new(options::HEADER) .long(options::HEADER) .help( "print (without converting) the first N header lines; \ N defaults to 1 if not specified", ) .value_name("N") - .default_value(options::HEADER_DEFAULT) + .default_missing_value(options::HEADER_DEFAULT) .hide_default_value(true), ) .arg( - Arg::with_name(options::ROUND) + Arg::new(options::ROUND) .long(options::ROUND) .help( "use METHOD for rounding when scaling; METHOD can be: up,\ @@ -246,7 +246,7 @@ pub fn uu_app() -> App<'static, 'static> { .possible_values(&["up", "down", "from-zero", "towards-zero", "nearest"]), ) .arg( - Arg::with_name(options::SUFFIX) + Arg::new(options::SUFFIX) .long(options::SUFFIX) .help( "print SUFFIX after each formatted number, and accept \ @@ -254,5 +254,9 @@ pub fn uu_app() -> App<'static, 'static> { ) .value_name("SUFFIX"), ) - .arg(Arg::with_name(options::NUMBER).hidden(true).multiple(true)) + .arg( + Arg::new(options::NUMBER) + .hide(true) + .multiple_occurrences(true), + ) } diff --git a/src/uu/od/Cargo.toml b/src/uu/od/Cargo.toml index 5fccc3281..1ab4e7051 100644 --- a/src/uu/od/Cargo.toml +++ b/src/uu/od/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_od" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "od ~ (uutils) display formatted representation of input" @@ -16,7 +16,7 @@ path = "src/od.rs" [dependencies] byteorder = "1.3.2" -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } half = "1.6" libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/od/src/od.rs b/src/uu/od/src/od.rs index 4a2f6b519..25a27038b 100644 --- a/src/uu/od/src/od.rs +++ b/src/uu/od/src/od.rs @@ -42,7 +42,7 @@ use crate::parse_nrofbytes::parse_number_of_bytes; use crate::partialreader::*; use crate::peekreader::*; use crate::prn_char::format_ascii_dump; -use clap::{self, crate_version, AppSettings, Arg, ArgMatches}; +use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; use uucore::display::Quotable; use uucore::error::{UResult, USimpleError}; use uucore::parse_size::ParseSizeError; @@ -286,229 +286,227 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { odfunc(&mut input_offset, &mut input_decoder, &output_info) } -pub fn uu_app() -> clap::App<'static, 'static> { - clap::App::new(uucore::util_name()) +pub fn uu_app<'a>() -> App<'a> { + App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) - .usage(USAGE) + .override_usage(USAGE) .after_help(LONG_HELP) + .setting( + AppSettings::TrailingVarArg | + AppSettings::DontDelimitTrailingValues | + AppSettings::DeriveDisplayOrder + ) .arg( - Arg::with_name(options::ADDRESS_RADIX) - .short("A") + Arg::new(options::ADDRESS_RADIX) + .short('A') .long(options::ADDRESS_RADIX) .help("Select the base in which file offsets are printed.") .value_name("RADIX"), ) .arg( - Arg::with_name(options::SKIP_BYTES) - .short("j") + Arg::new(options::SKIP_BYTES) + .short('j') .long(options::SKIP_BYTES) .help("Skip bytes input bytes before formatting and writing.") .value_name("BYTES"), ) .arg( - Arg::with_name(options::READ_BYTES) - .short("N") + Arg::new(options::READ_BYTES) + .short('N') .long(options::READ_BYTES) .help("limit dump to BYTES input bytes") .value_name("BYTES"), ) .arg( - Arg::with_name(options::ENDIAN) + Arg::new(options::ENDIAN) .long(options::ENDIAN) .help("byte order to use for multi-byte formats") .possible_values(&["big", "little"]) .value_name("big|little"), ) .arg( - Arg::with_name(options::STRINGS) - .short("S") + Arg::new(options::STRINGS) + .short('S') .long(options::STRINGS) .help( "NotImplemented: output strings of at least BYTES graphic chars. 3 is assumed when \ BYTES is not specified.", ) - .default_value("3") + .default_missing_value("3") .value_name("BYTES"), ) .arg( - Arg::with_name("a") - .short("a") + Arg::new("a") + .short('a') .help("named characters, ignoring high-order bit") - .multiple(true) + .multiple_occurrences(true) .takes_value(false), ) .arg( - Arg::with_name("b") - .short("b") + Arg::new("b") + .short('b') .help("octal bytes") - .multiple(true) + .multiple_occurrences(true) .takes_value(false), ) .arg( - Arg::with_name("c") - .short("c") + Arg::new("c") + .short('c') .help("ASCII characters or backslash escapes") - .multiple(true) + .multiple_occurrences(true) .takes_value(false), ) .arg( - Arg::with_name("d") - .short("d") + Arg::new("d") + .short('d') .help("unsigned decimal 2-byte units") - .multiple(true) + .multiple_occurrences(true) .takes_value(false), ) .arg( - Arg::with_name("D") - .short("D") + Arg::new("D") + .short('D') .help("unsigned decimal 4-byte units") - .multiple(true) + .multiple_occurrences(true) .takes_value(false), ) .arg( - Arg::with_name("o") - .short("o") + Arg::new("o") + .short('o') .help("octal 2-byte units") - .multiple(true) + .multiple_occurrences(true) .takes_value(false), ) .arg( - Arg::with_name("I") - .short("I") + Arg::new("I") + .short('I') .help("decimal 8-byte units") - .multiple(true) + .multiple_occurrences(true) .takes_value(false), ) .arg( - Arg::with_name("L") - .short("L") + Arg::new("L") + .short('L') .help("decimal 8-byte units") - .multiple(true) + .multiple_occurrences(true) .takes_value(false), ) .arg( - Arg::with_name("i") - .short("i") + Arg::new("i") + .short('i') .help("decimal 4-byte units") - .multiple(true) + .multiple_occurrences(true) .takes_value(false), ) .arg( - Arg::with_name("l") - .short("l") + Arg::new("l") + .short('l') .help("decimal 8-byte units") - .multiple(true) + .multiple_occurrences(true) .takes_value(false), ) .arg( - Arg::with_name("x") - .short("x") + Arg::new("x") + .short('x') .help("hexadecimal 2-byte units") - .multiple(true) + .multiple_occurrences(true) .takes_value(false), ) .arg( - Arg::with_name("h") - .short("h") + Arg::new("h") + .short('h') .help("hexadecimal 2-byte units") - .multiple(true) + .multiple_occurrences(true) .takes_value(false), ) .arg( - Arg::with_name("O") - .short("O") + Arg::new("O") + .short('O') .help("octal 4-byte units") - .multiple(true) + .multiple_occurrences(true) .takes_value(false), ) .arg( - Arg::with_name("s") - .short("s") + Arg::new("s") + .short('s') .help("decimal 2-byte units") - .multiple(true) + .multiple_occurrences(true) .takes_value(false), ) .arg( - Arg::with_name("X") - .short("X") + Arg::new("X") + .short('X') .help("hexadecimal 4-byte units") - .multiple(true) + .multiple_occurrences(true) .takes_value(false), ) .arg( - Arg::with_name("H") - .short("H") + Arg::new("H") + .short('H') .help("hexadecimal 4-byte units") - .multiple(true) + .multiple_occurrences(true) .takes_value(false), ) .arg( - Arg::with_name("e") - .short("e") + Arg::new("e") + .short('e') .help("floating point double precision (64-bit) units") - .multiple(true) + .multiple_occurrences(true) .takes_value(false), ) .arg( - Arg::with_name("f") - .short("f") + Arg::new("f") + .short('f') .help("floating point double precision (32-bit) units") - .multiple(true) + .multiple_occurrences(true) .takes_value(false), ) .arg( - Arg::with_name("F") - .short("F") + Arg::new("F") + .short('F') .help("floating point double precision (64-bit) units") - .multiple(true) + .multiple_occurrences(true) .takes_value(false), ) .arg( - Arg::with_name(options::FORMAT) - .short("t") - .long(options::FORMAT) + Arg::new(options::FORMAT) + .short('t') + .long("format") .help("select output format or formats") - .multiple(true) + .multiple_occurrences(true) .number_of_values(1) .value_name("TYPE"), ) .arg( - Arg::with_name(options::OUTPUT_DUPLICATES) - .short("v") + Arg::new(options::OUTPUT_DUPLICATES) + .short('v') .long(options::OUTPUT_DUPLICATES) .help("do not use * to mark line suppression") - .takes_value(false) - .possible_values(&["big", "little"]), + .takes_value(false), ) .arg( - Arg::with_name(options::WIDTH) - .short("w") + Arg::new(options::WIDTH) + .short('w') .long(options::WIDTH) .help( "output BYTES bytes per output line. 32 is implied when BYTES is not \ specified.", ) - .default_value("32") + .default_missing_value("32") .value_name("BYTES"), ) .arg( - Arg::with_name(options::TRADITIONAL) + Arg::new(options::TRADITIONAL) .long(options::TRADITIONAL) .help("compatibility mode with one input, offset and label.") .takes_value(false), ) .arg( - Arg::with_name(options::FILENAME) - .hidden(true) - .multiple(true), + Arg::new(options::FILENAME) + .hide(true) + .multiple_occurrences(true), ) - .settings(&[ - AppSettings::TrailingVarArg, - AppSettings::DontDelimitTrailingValues, - AppSettings::DisableVersion, - AppSettings::DeriveDisplayOrder, - ]) } /// Loops through the input line by line, calling print_bytes to take care of the output. diff --git a/src/uu/od/src/parse_inputs.rs b/src/uu/od/src/parse_inputs.rs index 419b7173d..a5634c0aa 100644 --- a/src/uu/od/src/parse_inputs.rs +++ b/src/uu/od/src/parse_inputs.rs @@ -10,7 +10,7 @@ pub trait CommandLineOpts { } /// Implementation for `getopts` -impl<'a> CommandLineOpts for ArgMatches<'a> { +impl<'a> CommandLineOpts for ArgMatches { fn inputs(&self) -> Vec<&str> { self.values_of(options::FILENAME) .map(|values| values.collect()) @@ -53,7 +53,14 @@ pub fn parse_inputs(matches: &dyn CommandLineOpts) -> Result Result { #[cfg(test)] mod tests { use super::*; - - /// A mock for the command line options type - /// - /// `inputs` are all command line parameters which do not belong to an option. - /// `option_names` are the names of the options on the command line. - struct MockOptions<'a> { - inputs: Vec, - option_names: Vec<&'a str>, - } - - impl<'a> MockOptions<'a> { - fn new(inputs: Vec<&'a str>, option_names: Vec<&'a str>) -> MockOptions<'a> { - MockOptions { - inputs: inputs.iter().map(|&s| s.to_string()).collect::>(), - option_names, - } - } - } - - impl<'a> CommandLineOpts for MockOptions<'a> { - fn inputs(&self) -> Vec<&str> { - self.inputs.iter().map(|s| s.as_str()).collect() - } - fn opts_present(&self, opts: &[&str]) -> bool { - for expected in opts.iter() { - for actual in self.option_names.iter() { - if *expected == *actual { - return true; - } - } - } - false - } - } + use crate::uu_app; #[test] fn test_parse_inputs_normal() { assert_eq!( CommandLineInputs::FileNames(vec!["-".to_string()]), - parse_inputs(&MockOptions::new(vec![], vec![])).unwrap() + parse_inputs(&uu_app().get_matches_from(vec!["od"])).unwrap() ); assert_eq!( CommandLineInputs::FileNames(vec!["-".to_string()]), - parse_inputs(&MockOptions::new(vec!["-"], vec![])).unwrap() + parse_inputs(&uu_app().get_matches_from(vec!["od", "-"])).unwrap() ); assert_eq!( CommandLineInputs::FileNames(vec!["file1".to_string()]), - parse_inputs(&MockOptions::new(vec!["file1"], vec![])).unwrap() + parse_inputs(&uu_app().get_matches_from(vec!["od", "file1"])).unwrap() ); assert_eq!( CommandLineInputs::FileNames(vec!["file1".to_string(), "file2".to_string()]), - parse_inputs(&MockOptions::new(vec!["file1", "file2"], vec![])).unwrap() + parse_inputs(&uu_app().get_matches_from(vec!["od", "file1", "file2"])).unwrap() ); assert_eq!( @@ -229,7 +203,7 @@ mod tests { "file1".to_string(), "file2".to_string(), ]), - parse_inputs(&MockOptions::new(vec!["-", "file1", "file2"], vec![])).unwrap() + parse_inputs(&uu_app().get_matches_from(vec!["od", "-", "file1", "file2"])).unwrap() ); } @@ -238,58 +212,58 @@ mod tests { // offset is found without filename, so stdin will be used. assert_eq!( CommandLineInputs::FileAndOffset(("-".to_string(), 8, None)), - parse_inputs(&MockOptions::new(vec!["+10"], vec![])).unwrap() + parse_inputs(&uu_app().get_matches_from(vec!["od", "+10"])).unwrap() ); // offset must start with "+" if no input is specified. assert_eq!( CommandLineInputs::FileNames(vec!["10".to_string()]), - parse_inputs(&MockOptions::new(vec!["10"], vec![""])).unwrap() + parse_inputs(&uu_app().get_matches_from(vec!["od", "10"])).unwrap() ); // offset is not valid, so it is considered a filename. assert_eq!( CommandLineInputs::FileNames(vec!["+10a".to_string()]), - parse_inputs(&MockOptions::new(vec!["+10a"], vec![""])).unwrap() + parse_inputs(&uu_app().get_matches_from(vec!["od", "+10a"])).unwrap() ); // if -j is included in the command line, there cannot be an offset. assert_eq!( CommandLineInputs::FileNames(vec!["+10".to_string()]), - parse_inputs(&MockOptions::new(vec!["+10"], vec!["j"])).unwrap() + parse_inputs(&uu_app().get_matches_from(vec!["od", "-j10", "+10"])).unwrap() ); // if -v is included in the command line, there cannot be an offset. assert_eq!( CommandLineInputs::FileNames(vec!["+10".to_string()]), - parse_inputs(&MockOptions::new(vec!["+10"], vec!["o", "v"])).unwrap() + parse_inputs(&uu_app().get_matches_from(vec!["od", "-o", "-v", "+10"])).unwrap() ); assert_eq!( CommandLineInputs::FileAndOffset(("file1".to_string(), 8, None)), - parse_inputs(&MockOptions::new(vec!["file1", "+10"], vec![])).unwrap() + parse_inputs(&uu_app().get_matches_from(vec!["od", "file1", "+10"])).unwrap() ); // offset does not need to start with "+" if a filename is included. assert_eq!( CommandLineInputs::FileAndOffset(("file1".to_string(), 8, None)), - parse_inputs(&MockOptions::new(vec!["file1", "10"], vec![])).unwrap() + parse_inputs(&uu_app().get_matches_from(vec!["od", "file1", "10"])).unwrap() ); assert_eq!( CommandLineInputs::FileNames(vec!["file1".to_string(), "+10a".to_string()]), - parse_inputs(&MockOptions::new(vec!["file1", "+10a"], vec![""])).unwrap() + parse_inputs(&uu_app().get_matches_from(vec!["od", "file1", "+10a"])).unwrap() ); assert_eq!( CommandLineInputs::FileNames(vec!["file1".to_string(), "+10".to_string()]), - parse_inputs(&MockOptions::new(vec!["file1", "+10"], vec!["j"])).unwrap() + parse_inputs(&uu_app().get_matches_from(vec!["od", "-j10", "file1", "+10"])).unwrap() ); // offset must be last on the command line assert_eq!( CommandLineInputs::FileNames(vec!["+10".to_string(), "file1".to_string()]), - parse_inputs(&MockOptions::new(vec!["+10", "file1"], vec![""])).unwrap() + parse_inputs(&uu_app().get_matches_from(vec!["od", "+10", "file1"])).unwrap() ); } @@ -298,59 +272,63 @@ mod tests { // it should not return FileAndOffset to signal no offset was entered on the command line. assert_eq!( CommandLineInputs::FileNames(vec!["-".to_string()]), - parse_inputs(&MockOptions::new(vec![], vec!["traditional"])).unwrap() + parse_inputs(&uu_app().get_matches_from(vec!["od", "--traditional"])).unwrap() ); assert_eq!( CommandLineInputs::FileNames(vec!["file1".to_string()]), - parse_inputs(&MockOptions::new(vec!["file1"], vec!["traditional"])).unwrap() + parse_inputs(&uu_app().get_matches_from(vec!["od", "--traditional", "file1"])).unwrap() ); // offset does not need to start with a + assert_eq!( CommandLineInputs::FileAndOffset(("-".to_string(), 8, None)), - parse_inputs(&MockOptions::new(vec!["10"], vec!["traditional"])).unwrap() + parse_inputs(&uu_app().get_matches_from(vec!["od", "--traditional", "10"])).unwrap() ); // valid offset and valid label assert_eq!( CommandLineInputs::FileAndOffset(("-".to_string(), 8, Some(8))), - parse_inputs(&MockOptions::new(vec!["10", "10"], vec!["traditional"])).unwrap() + parse_inputs(&uu_app().get_matches_from(vec!["od", "--traditional", "10", "10"])) + .unwrap() ); assert_eq!( CommandLineInputs::FileAndOffset(("file1".to_string(), 8, None)), - parse_inputs(&MockOptions::new(vec!["file1", "10"], vec!["traditional"])).unwrap() + parse_inputs(&uu_app().get_matches_from(vec!["od", "--traditional", "file1", "10"])) + .unwrap() ); // only one file is allowed, it must be the first - parse_inputs(&MockOptions::new(vec!["10", "file1"], vec!["traditional"])).unwrap_err(); + parse_inputs(&uu_app().get_matches_from(vec!["od", "--traditional", "10", "file1"])) + .unwrap_err(); assert_eq!( CommandLineInputs::FileAndOffset(("file1".to_string(), 8, Some(8))), - parse_inputs(&MockOptions::new( - vec!["file1", "10", "10"], - vec!["traditional"] - )) + parse_inputs(&uu_app().get_matches_from(vec![ + "od", + "--traditional", + "file1", + "10", + "10" + ])) .unwrap() ); - parse_inputs(&MockOptions::new( - vec!["10", "file1", "10"], - vec!["traditional"], - )) - .unwrap_err(); + parse_inputs(&uu_app().get_matches_from(vec!["od", "--traditional", "10", "file1", "10"])) + .unwrap_err(); - parse_inputs(&MockOptions::new( - vec!["10", "10", "file1"], - vec!["traditional"], - )) - .unwrap_err(); + parse_inputs(&uu_app().get_matches_from(vec!["od", "--traditional", "10", "10", "file1"])) + .unwrap_err(); - parse_inputs(&MockOptions::new( - vec!["10", "10", "10", "10"], - vec!["traditional"], - )) + parse_inputs(&uu_app().get_matches_from(vec![ + "od", + "--traditional", + "10", + "10", + "10", + "10", + ])) .unwrap_err(); } diff --git a/src/uu/paste/Cargo.toml b/src/uu/paste/Cargo.toml index a060ff37f..87ac9ab20 100644 --- a/src/uu/paste/Cargo.toml +++ b/src/uu/paste/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_paste" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "paste ~ (uutils) merge lines from inputs" @@ -15,7 +15,7 @@ edition = "2018" path = "src/paste.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/paste/src/paste.rs b/src/uu/paste/src/paste.rs index a6e2b8604..72887d0d7 100644 --- a/src/uu/paste/src/paste.rs +++ b/src/uu/paste/src/paste.rs @@ -48,29 +48,29 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { paste(files, serial, delimiters) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(options::SERIAL) + Arg::new(options::SERIAL) .long(options::SERIAL) - .short("s") + .short('s') .help("paste one file at a time instead of in parallel"), ) .arg( - Arg::with_name(options::DELIMITER) + Arg::new(options::DELIMITER) .long(options::DELIMITER) - .short("d") + .short('d') .help("reuse characters from LIST instead of TABs") .value_name("LIST") .default_value("\t") .hide_default_value(true), ) .arg( - Arg::with_name(options::FILE) + Arg::new(options::FILE) .value_name("FILE") - .multiple(true) + .multiple_occurrences(true) .default_value("-"), ) } diff --git a/src/uu/pathchk/Cargo.toml b/src/uu/pathchk/Cargo.toml index 04b2affff..09f0b133d 100644 --- a/src/uu/pathchk/Cargo.toml +++ b/src/uu/pathchk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_pathchk" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "pathchk ~ (uutils) diagnose invalid or non-portable PATHNAME" @@ -15,7 +15,7 @@ edition = "2018" path = "src/pathchk.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/pathchk/src/pathchk.rs b/src/uu/pathchk/src/pathchk.rs index fa6aaad5b..0ef2ddc90 100644 --- a/src/uu/pathchk/src/pathchk.rs +++ b/src/uu/pathchk/src/pathchk.rs @@ -47,7 +47,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { .collect_str(InvalidEncodingHandling::ConvertLossy) .accept_any(); - let matches = uu_app().usage(&usage[..]).get_matches_from(args); + let matches = uu_app().override_usage(&usage[..]).get_matches_from(args); // set working mode let is_posix = matches.values_of(options::POSIX).is_some(); @@ -88,26 +88,30 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(options::POSIX) - .short("p") + Arg::new(options::POSIX) + .short('p') .help("check for most POSIX systems"), ) .arg( - Arg::with_name(options::POSIX_SPECIAL) - .short("P") + Arg::new(options::POSIX_SPECIAL) + .short('P') .help(r#"check for empty names and leading "-""#), ) .arg( - Arg::with_name(options::PORTABILITY) + Arg::new(options::PORTABILITY) .long(options::PORTABILITY) .help("check for all POSIX systems (equivalent to -p -P)"), ) - .arg(Arg::with_name(options::PATH).hidden(true).multiple(true)) + .arg( + Arg::new(options::PATH) + .hide(true) + .multiple_occurrences(true), + ) } // check a path, given as a slice of it's components and an operating mode diff --git a/src/uu/pinky/Cargo.toml b/src/uu/pinky/Cargo.toml index 55398415c..b07a39aa1 100644 --- a/src/uu/pinky/Cargo.toml +++ b/src/uu/pinky/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_pinky" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "pinky ~ (uutils) display user information" @@ -15,9 +15,9 @@ edition = "2018" path = "src/pinky.rs" [dependencies] +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["utmpx", "entries"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } -clap = { version = "2.33", features = ["wrap_help"] } [[bin]] name = "pinky" diff --git a/src/uu/pinky/src/pinky.rs b/src/uu/pinky/src/pinky.rs index 8220affc5..d3b38073f 100644 --- a/src/uu/pinky/src/pinky.rs +++ b/src/uu/pinky/src/pinky.rs @@ -61,7 +61,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let after_help = get_long_usage(); let matches = uu_app() - .usage(&usage[..]) + .override_usage(&usage[..]) .after_help(&after_help[..]) .get_matches_from(args); @@ -132,60 +132,60 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(options::LONG_FORMAT) - .short("l") + Arg::new(options::LONG_FORMAT) + .short('l') .requires(options::USER) .help("produce long format output for the specified USERs"), ) .arg( - Arg::with_name(options::OMIT_HOME_DIR) - .short("b") + Arg::new(options::OMIT_HOME_DIR) + .short('b') .help("omit the user's home directory and shell in long format"), ) .arg( - Arg::with_name(options::OMIT_PROJECT_FILE) - .short("h") + Arg::new(options::OMIT_PROJECT_FILE) + .short('h') .help("omit the user's project file in long format"), ) .arg( - Arg::with_name(options::OMIT_PLAN_FILE) - .short("p") + Arg::new(options::OMIT_PLAN_FILE) + .short('p') .help("omit the user's plan file in long format"), ) .arg( - Arg::with_name(options::SHORT_FORMAT) - .short("s") + Arg::new(options::SHORT_FORMAT) + .short('s') .help("do short format output, this is the default"), ) .arg( - Arg::with_name(options::OMIT_HEADINGS) - .short("f") + Arg::new(options::OMIT_HEADINGS) + .short('f') .help("omit the line of column headings in short format"), ) .arg( - Arg::with_name(options::OMIT_NAME) - .short("w") + Arg::new(options::OMIT_NAME) + .short('w') .help("omit the user's full name in short format"), ) .arg( - Arg::with_name(options::OMIT_NAME_HOST) - .short("i") + Arg::new(options::OMIT_NAME_HOST) + .short('i') .help("omit the user's full name and remote host in short format"), ) .arg( - Arg::with_name(options::OMIT_NAME_HOST_TIME) - .short("q") + Arg::new(options::OMIT_NAME_HOST_TIME) + .short('q') .help("omit the user's full name, remote host and idle time in short format"), ) .arg( - Arg::with_name(options::USER) + Arg::new(options::USER) .takes_value(true) - .multiple(true), + .multiple_occurrences(true), ) } diff --git a/src/uu/pr/Cargo.toml b/src/uu/pr/Cargo.toml index 4fe6ab460..567594501 100644 --- a/src/uu/pr/Cargo.toml +++ b/src/uu/pr/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_pr" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "pr ~ (uutils) convert text files for printing" @@ -15,7 +15,7 @@ edition = "2018" path = "src/pr.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["entries"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } getopts = "0.2.21" diff --git a/src/uu/pr/src/pr.rs b/src/uu/pr/src/pr.rs index ea6fb86a8..e985492db 100644 --- a/src/uu/pr/src/pr.rs +++ b/src/uu/pr/src/pr.rs @@ -13,6 +13,7 @@ extern crate quick_error; use chrono::offset::Local; use chrono::DateTime; +use clap::App; use getopts::Matches; use getopts::{HasArg, Occur}; use itertools::Itertools; @@ -170,9 +171,8 @@ quick_error! { } } -pub fn uu_app() -> clap::App<'static, 'static> { - // TODO: migrate to clap to get more shell completions - clap::App::new(uucore::util_name()) +pub fn uu_app<'a>() -> App<'a> { + App::new(uucore::util_name()) } #[uucore_procs::gen_uumain] diff --git a/src/uu/printenv/Cargo.toml b/src/uu/printenv/Cargo.toml index 089d32782..b43012700 100644 --- a/src/uu/printenv/Cargo.toml +++ b/src/uu/printenv/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_printenv" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "printenv ~ (uutils) display value of environment VAR" @@ -15,7 +15,7 @@ edition = "2018" path = "src/printenv.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/printenv/src/printenv.rs b/src/uu/printenv/src/printenv.rs index c3f996865..747d7fa7e 100644 --- a/src/uu/printenv/src/printenv.rs +++ b/src/uu/printenv/src/printenv.rs @@ -25,7 +25,7 @@ fn usage() -> String { pub fn uumain(args: impl uucore::Args) -> UResult<()> { 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 variables: Vec = matches .values_of(ARG_VARIABLES) @@ -61,19 +61,19 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(OPT_NULL) - .short("0") + Arg::new(OPT_NULL) + .short('0') .long(OPT_NULL) .help("end each output line with 0 byte rather than newline"), ) .arg( - Arg::with_name(ARG_VARIABLES) - .multiple(true) + Arg::new(ARG_VARIABLES) + .multiple_occurrences(true) .takes_value(true) .min_values(1), ) diff --git a/src/uu/printf/Cargo.toml b/src/uu/printf/Cargo.toml index 09a5640a8..b1ffc8af1 100644 --- a/src/uu/printf/Cargo.toml +++ b/src/uu/printf/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_printf" -version = "0.0.9" +version = "0.0.12" authors = [ "Nathan Ross", "uutils developers", @@ -18,7 +18,7 @@ edition = "2018" path = "src/printf.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } itertools = "0.8.0" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/printf/src/printf.rs b/src/uu/printf/src/printf.rs index b49057522..53c4d7934 100644 --- a/src/uu/printf/src/printf.rs +++ b/src/uu/printf/src/printf.rs @@ -296,8 +296,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) - .arg(Arg::with_name(VERSION).long(VERSION)) - .arg(Arg::with_name(HELP).long(HELP)) + .arg(Arg::new(VERSION).long(VERSION)) + .arg(Arg::new(HELP).long(HELP)) } diff --git a/src/uu/ptx/Cargo.toml b/src/uu/ptx/Cargo.toml index 436e0cdb6..33d6d46cd 100644 --- a/src/uu/ptx/Cargo.toml +++ b/src/uu/ptx/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_ptx" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "ptx ~ (uutils) display a permuted index of input" @@ -15,7 +15,7 @@ edition = "2018" path = "src/ptx.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } aho-corasick = "0.7.3" libc = "0.2.42" memchr = "2.2.0" diff --git a/src/uu/ptx/src/ptx.rs b/src/uu/ptx/src/ptx.rs index f1650c81d..54cd69b01 100644 --- a/src/uu/ptx/src/ptx.rs +++ b/src/uu/ptx/src/ptx.rs @@ -683,7 +683,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { // let mut opts = Options::new(); let matches = uu_app().get_matches_from(args); - let input_files: Vec = match &matches.values_of(options::FILE) { + let mut input_files: Vec = match &matches.values_of(options::FILE) { Some(v) => v.clone().map(|v| v.to_owned()).collect(), None => vec!["-".to_string()], }; @@ -692,134 +692,138 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let word_filter = WordFilter::new(&matches, &config)?; let file_map = read_input(&input_files, &config).map_err_context(String::new)?; let word_set = create_word_set(&config, &word_filter, &file_map); - let output_file = if !config.gnu_ext && matches.args.len() == 2 { - matches.value_of(options::FILE).unwrap_or("-").to_string() + let output_file = if !config.gnu_ext && input_files.len() == 2 { + input_files.pop().unwrap() } else { - "-".to_owned() + "-".to_string() }; write_traditional_output(&config, &file_map, &word_set, &output_file) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .name(NAME) .version(crate_version!()) - .usage(BRIEF) - .arg(Arg::with_name(options::FILE).hidden(true).multiple(true)) + .override_usage(BRIEF) .arg( - Arg::with_name(options::AUTO_REFERENCE) - .short("A") + Arg::new(options::FILE) + .hide(true) + .multiple_occurrences(true), + ) + .arg( + Arg::new(options::AUTO_REFERENCE) + .short('A') .long(options::AUTO_REFERENCE) .help("output automatically generated references") .takes_value(false), ) .arg( - Arg::with_name(options::TRADITIONAL) - .short("G") + Arg::new(options::TRADITIONAL) + .short('G') .long(options::TRADITIONAL) .help("behave more like System V 'ptx'"), ) .arg( - Arg::with_name(options::FLAG_TRUNCATION) - .short("F") + Arg::new(options::FLAG_TRUNCATION) + .short('F') .long(options::FLAG_TRUNCATION) .help("use STRING for flagging line truncations") .value_name("STRING") .takes_value(true), ) .arg( - Arg::with_name(options::MACRO_NAME) - .short("M") + Arg::new(options::MACRO_NAME) + .short('M') .long(options::MACRO_NAME) .help("macro name to use instead of 'xx'") .value_name("STRING") .takes_value(true), ) .arg( - Arg::with_name(options::FORMAT_ROFF) - .short("O") + Arg::new(options::FORMAT_ROFF) + .short('O') .long(options::FORMAT_ROFF) .help("generate output as roff directives"), ) .arg( - Arg::with_name(options::RIGHT_SIDE_REFS) - .short("R") + Arg::new(options::RIGHT_SIDE_REFS) + .short('R') .long(options::RIGHT_SIDE_REFS) .help("put references at right, not counted in -w") .takes_value(false), ) .arg( - Arg::with_name(options::SENTENCE_REGEXP) - .short("S") + Arg::new(options::SENTENCE_REGEXP) + .short('S') .long(options::SENTENCE_REGEXP) .help("for end of lines or end of sentences") .value_name("REGEXP") .takes_value(true), ) .arg( - Arg::with_name(options::FORMAT_TEX) - .short("T") + Arg::new(options::FORMAT_TEX) + .short('T') .long(options::FORMAT_TEX) .help("generate output as TeX directives"), ) .arg( - Arg::with_name(options::WORD_REGEXP) - .short("W") + Arg::new(options::WORD_REGEXP) + .short('W') .long(options::WORD_REGEXP) .help("use REGEXP to match each keyword") .value_name("REGEXP") .takes_value(true), ) .arg( - Arg::with_name(options::BREAK_FILE) - .short("b") + Arg::new(options::BREAK_FILE) + .short('b') .long(options::BREAK_FILE) .help("word break characters in this FILE") .value_name("FILE") .takes_value(true), ) .arg( - Arg::with_name(options::IGNORE_CASE) - .short("f") + Arg::new(options::IGNORE_CASE) + .short('f') .long(options::IGNORE_CASE) .help("fold lower case to upper case for sorting") .takes_value(false), ) .arg( - Arg::with_name(options::GAP_SIZE) - .short("g") + Arg::new(options::GAP_SIZE) + .short('g') .long(options::GAP_SIZE) .help("gap size in columns between output fields") .value_name("NUMBER") .takes_value(true), ) .arg( - Arg::with_name(options::IGNORE_FILE) - .short("i") + Arg::new(options::IGNORE_FILE) + .short('i') .long(options::IGNORE_FILE) .help("read ignore word list from FILE") .value_name("FILE") .takes_value(true), ) .arg( - Arg::with_name(options::ONLY_FILE) - .short("o") + Arg::new(options::ONLY_FILE) + .short('o') .long(options::ONLY_FILE) .help("read only word list from this FILE") .value_name("FILE") .takes_value(true), ) .arg( - Arg::with_name(options::REFERENCES) - .short("r") + Arg::new(options::REFERENCES) + .short('r') .long(options::REFERENCES) .help("first field of each line is a reference") .value_name("FILE") .takes_value(false), ) .arg( - Arg::with_name(options::WIDTH) - .short("w") + Arg::new(options::WIDTH) + .short('w') .long(options::WIDTH) .help("output width in columns, reference excluded") .value_name("NUMBER") diff --git a/src/uu/pwd/Cargo.toml b/src/uu/pwd/Cargo.toml index 628459d2b..a6cccb0f1 100644 --- a/src/uu/pwd/Cargo.toml +++ b/src/uu/pwd/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_pwd" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "pwd ~ (uutils) display current working directory" @@ -15,7 +15,7 @@ edition = "2018" path = "src/pwd.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/pwd/src/pwd.rs b/src/uu/pwd/src/pwd.rs index 4b4819ed5..f152fa58a 100644 --- a/src/uu/pwd/src/pwd.rs +++ b/src/uu/pwd/src/pwd.rs @@ -128,7 +128,7 @@ fn usage() -> String { pub fn uumain(args: impl uucore::Args) -> UResult<()> { 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 cwd = if matches.is_present(OPT_LOGICAL) { logical_path() } else { @@ -152,19 +152,19 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(OPT_LOGICAL) - .short("L") + Arg::new(OPT_LOGICAL) + .short('L') .long(OPT_LOGICAL) .help("use PWD from environment, even if it contains symlinks"), ) .arg( - Arg::with_name(OPT_PHYSICAL) - .short("P") + Arg::new(OPT_PHYSICAL) + .short('P') .long(OPT_PHYSICAL) .overrides_with(OPT_LOGICAL) .help("avoid all symlinks"), diff --git a/src/uu/readlink/Cargo.toml b/src/uu/readlink/Cargo.toml index deb05200c..35be61542 100644 --- a/src/uu/readlink/Cargo.toml +++ b/src/uu/readlink/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_readlink" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "readlink ~ (uutils) display resolved path of PATHNAME" @@ -15,7 +15,7 @@ edition = "2018" path = "src/readlink.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/readlink/src/readlink.rs b/src/uu/readlink/src/readlink.rs index 85b436be1..a33c0feeb 100644 --- a/src/uu/readlink/src/readlink.rs +++ b/src/uu/readlink/src/readlink.rs @@ -37,7 +37,7 @@ fn usage() -> String { #[uucore_procs::gen_uumain] pub fn uumain(args: impl uucore::Args) -> UResult<()> { 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 mut no_newline = matches.is_present(OPT_NO_NEWLINE); let use_zero = matches.is_present(OPT_ZERO); @@ -98,13 +98,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(OPT_CANONICALIZE) - .short("f") + Arg::new(OPT_CANONICALIZE) + .short('f') .long(OPT_CANONICALIZE) .help( "canonicalize by following every symlink in every component of the \ @@ -112,8 +112,8 @@ pub fn uu_app() -> App<'static, 'static> { ), ) .arg( - Arg::with_name(OPT_CANONICALIZE_EXISTING) - .short("e") + Arg::new(OPT_CANONICALIZE_EXISTING) + .short('e') .long("canonicalize-existing") .help( "canonicalize by following every symlink in every component of the \ @@ -121,8 +121,8 @@ pub fn uu_app() -> App<'static, 'static> { ), ) .arg( - Arg::with_name(OPT_CANONICALIZE_MISSING) - .short("m") + Arg::new(OPT_CANONICALIZE_MISSING) + .short('m') .long(OPT_CANONICALIZE_MISSING) .help( "canonicalize by following every symlink in every component of the \ @@ -130,36 +130,40 @@ pub fn uu_app() -> App<'static, 'static> { ), ) .arg( - Arg::with_name(OPT_NO_NEWLINE) - .short("n") + Arg::new(OPT_NO_NEWLINE) + .short('n') .long(OPT_NO_NEWLINE) .help("do not output the trailing delimiter"), ) .arg( - Arg::with_name(OPT_QUIET) - .short("q") + Arg::new(OPT_QUIET) + .short('q') .long(OPT_QUIET) .help("suppress most error messages"), ) .arg( - Arg::with_name(OPT_SILENT) - .short("s") + Arg::new(OPT_SILENT) + .short('s') .long(OPT_SILENT) .help("suppress most error messages"), ) .arg( - Arg::with_name(OPT_VERBOSE) - .short("v") + Arg::new(OPT_VERBOSE) + .short('v') .long(OPT_VERBOSE) .help("report error message"), ) .arg( - Arg::with_name(OPT_ZERO) - .short("z") + Arg::new(OPT_ZERO) + .short('z') .long(OPT_ZERO) .help("separate output with NUL rather than newline"), ) - .arg(Arg::with_name(ARG_FILES).multiple(true).takes_value(true)) + .arg( + Arg::new(ARG_FILES) + .multiple_occurrences(true) + .takes_value(true), + ) } fn show(path: &Path, no_newline: bool, use_zero: bool) -> std::io::Result<()> { diff --git a/src/uu/realpath/Cargo.toml b/src/uu/realpath/Cargo.toml index c4ccb85dc..9c1919fb4 100644 --- a/src/uu/realpath/Cargo.toml +++ b/src/uu/realpath/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_realpath" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "realpath ~ (uutils) display resolved absolute path of PATHNAME" @@ -15,7 +15,7 @@ edition = "2018" path = "src/realpath.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/realpath/src/realpath.rs b/src/uu/realpath/src/realpath.rs index de8833341..9828a53bb 100644 --- a/src/uu/realpath/src/realpath.rs +++ b/src/uu/realpath/src/realpath.rs @@ -41,7 +41,7 @@ fn usage() -> String { pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); - let matches = uu_app().usage(&usage[..]).get_matches_from(args); + let matches = uu_app().override_usage(&usage[..]).get_matches_from(args); /* the list of files */ @@ -74,44 +74,44 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(OPT_QUIET) - .short("q") + Arg::new(OPT_QUIET) + .short('q') .long(OPT_QUIET) .help("Do not print warnings for invalid paths"), ) .arg( - Arg::with_name(OPT_STRIP) - .short("s") + Arg::new(OPT_STRIP) + .short('s') .long(OPT_STRIP) .help("Only strip '.' and '..' components, but don't resolve symbolic links"), ) .arg( - Arg::with_name(OPT_ZERO) - .short("z") + Arg::new(OPT_ZERO) + .short('z') .long(OPT_ZERO) .help("Separate output filenames with \\0 rather than newline"), ) .arg( - Arg::with_name(OPT_LOGICAL) - .short("L") + Arg::new(OPT_LOGICAL) + .short('L') .long(OPT_LOGICAL) .help("resolve '..' components before symlinks"), ) .arg( - Arg::with_name(OPT_PHYSICAL) - .short("P") + Arg::new(OPT_PHYSICAL) + .short('P') .long(OPT_PHYSICAL) .overrides_with_all(&[OPT_STRIP, OPT_LOGICAL]) .help("resolve symlinks as encountered (default)"), ) .arg( - Arg::with_name(OPT_CANONICALIZE_EXISTING) - .short("e") + Arg::new(OPT_CANONICALIZE_EXISTING) + .short('e') .long(OPT_CANONICALIZE_EXISTING) .help( "canonicalize by following every symlink in every component of the \ @@ -119,8 +119,8 @@ pub fn uu_app() -> App<'static, 'static> { ), ) .arg( - Arg::with_name(OPT_CANONICALIZE_MISSING) - .short("m") + Arg::new(OPT_CANONICALIZE_MISSING) + .short('m') .long(OPT_CANONICALIZE_MISSING) .help( "canonicalize by following every symlink in every component of the \ @@ -128,8 +128,8 @@ pub fn uu_app() -> App<'static, 'static> { ), ) .arg( - Arg::with_name(ARG_FILES) - .multiple(true) + Arg::new(ARG_FILES) + .multiple_occurrences(true) .takes_value(true) .required(true) .min_values(1), diff --git a/src/uu/relpath/Cargo.toml b/src/uu/relpath/Cargo.toml index 85214abe5..6c4894bca 100644 --- a/src/uu/relpath/Cargo.toml +++ b/src/uu/relpath/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_relpath" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "relpath ~ (uutils) display relative path of PATHNAME_TO from PATHNAME_FROM" @@ -15,7 +15,7 @@ edition = "2018" path = "src/relpath.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/relpath/src/relpath.rs b/src/uu/relpath/src/relpath.rs index 88c1f5506..c2d745671 100644 --- a/src/uu/relpath/src/relpath.rs +++ b/src/uu/relpath/src/relpath.rs @@ -35,7 +35,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { .accept_any(); 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 to = Path::new(matches.value_of(options::TO).unwrap()).to_path_buf(); // required let from = match matches.value_of(options::FROM) { @@ -82,23 +82,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { println_verbatim(result).map_err_context(String::new) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) - .arg( - Arg::with_name(options::DIR) - .short("d") - .takes_value(true) - .help("If any of FROM and TO is not subpath of DIR, output absolute path instead of relative"), - ) - .arg( - Arg::with_name(options::TO) - .required(true) - .takes_value(true), - ) - .arg( - Arg::with_name(options::FROM) - .takes_value(true), - ) + .arg(Arg::new(options::DIR).short('d').takes_value(true).help( + "If any of FROM and TO is not subpath of DIR, output absolute path instead of relative", + )) + .arg(Arg::new(options::TO).required(true).takes_value(true)) + .arg(Arg::new(options::FROM).takes_value(true)) } diff --git a/src/uu/rm/Cargo.toml b/src/uu/rm/Cargo.toml index 5d1470469..26dcc58fc 100644 --- a/src/uu/rm/Cargo.toml +++ b/src/uu/rm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_rm" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "rm ~ (uutils) remove PATHNAME" @@ -15,7 +15,7 @@ edition = "2018" path = "src/rm.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } walkdir = "2.2" remove_dir_all = "0.5.1" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } diff --git a/src/uu/rm/src/rm.rs b/src/uu/rm/src/rm.rs index 3183b0ac0..2974eb9cc 100644 --- a/src/uu/rm/src/rm.rs +++ b/src/uu/rm/src/rm.rs @@ -51,7 +51,7 @@ static OPT_PROMPT_MORE: &str = "prompt-more"; static OPT_RECURSIVE: &str = "recursive"; static OPT_RECURSIVE_R: &str = "recursive_R"; static OPT_VERBOSE: &str = "verbose"; -static PRESUME_INPUT_TTY: &str = "presume-input-tty"; +static PRESUME_INPUT_TTY: &str = "-presume-input-tty"; static ARG_FILES: &str = "files"; @@ -82,7 +82,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let long_usage = get_long_usage(); let matches = uu_app() - .usage(&usage[..]) + .override_usage(&usage[..]) .after_help(&long_usage[..]) .get_matches_from(args); @@ -145,71 +145,71 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(OPT_FORCE) - .short("f") + Arg::new(OPT_FORCE) + .short('f') .long(OPT_FORCE) - .multiple(true) + .multiple_occurrences(true) .help("ignore nonexistent files and arguments, never prompt") ) .arg( - Arg::with_name(OPT_PROMPT) - .short("i") + Arg::new(OPT_PROMPT) + .short('i') .long("prompt before every removal") ) .arg( - Arg::with_name(OPT_PROMPT_MORE) - .short("I") + Arg::new(OPT_PROMPT_MORE) + .short('I') .help("prompt once before removing more than three files, or when removing recursively. Less intrusive than -i, while still giving some protection against most mistakes") ) .arg( - Arg::with_name(OPT_INTERACTIVE) + Arg::new(OPT_INTERACTIVE) .long(OPT_INTERACTIVE) .help("prompt according to WHEN: never, once (-I), or always (-i). Without WHEN, prompts always") .value_name("WHEN") .takes_value(true) ) .arg( - Arg::with_name(OPT_ONE_FILE_SYSTEM) + Arg::new(OPT_ONE_FILE_SYSTEM) .long(OPT_ONE_FILE_SYSTEM) .help("when removing a hierarchy recursively, skip any directory that is on a file system different from that of the corresponding command line argument (NOT IMPLEMENTED)") ) .arg( - Arg::with_name(OPT_NO_PRESERVE_ROOT) + Arg::new(OPT_NO_PRESERVE_ROOT) .long(OPT_NO_PRESERVE_ROOT) .help("do not treat '/' specially") ) .arg( - Arg::with_name(OPT_PRESERVE_ROOT) + Arg::new(OPT_PRESERVE_ROOT) .long(OPT_PRESERVE_ROOT) .help("do not remove '/' (default)") ) .arg( - Arg::with_name(OPT_RECURSIVE).short("r") - .multiple(true) + Arg::new(OPT_RECURSIVE).short('r') + .multiple_occurrences(true) .long(OPT_RECURSIVE) .help("remove directories and their contents recursively") ) .arg( // To mimic GNU's behavior we also want the '-R' flag. However, using clap's // alias method 'visible_alias("R")' would result in a long '--R' flag. - Arg::with_name(OPT_RECURSIVE_R).short("R") + Arg::new(OPT_RECURSIVE_R).short('R') .help("Equivalent to -r") ) .arg( - Arg::with_name(OPT_DIR) - .short("d") + Arg::new(OPT_DIR) + .short('d') .long(OPT_DIR) .help("remove empty directories") ) .arg( - Arg::with_name(OPT_VERBOSE) - .short("v") + Arg::new(OPT_VERBOSE) + .short('v') .long(OPT_VERBOSE) .help("explain what is being done") ) @@ -219,14 +219,17 @@ pub fn uu_app() -> App<'static, 'static> { // It is relatively difficult to ensure that there is a tty on stdin. // Since rm acts differently depending on that, without this option, // it'd be harder to test the parts of rm that depend on that setting. + // In contrast with Arg::long, Arg::alias does not strip leading + // hyphens. Therefore it supports 3 leading hyphens. .arg( - Arg::with_name(PRESUME_INPUT_TTY) + Arg::new(PRESUME_INPUT_TTY) .long(PRESUME_INPUT_TTY) - .hidden(true) + .alias(PRESUME_INPUT_TTY) + .hide(true) ) .arg( - Arg::with_name(ARG_FILES) - .multiple(true) + Arg::new(ARG_FILES) + .multiple_occurrences(true) .takes_value(true) .min_values(1) ) diff --git a/src/uu/rmdir/Cargo.toml b/src/uu/rmdir/Cargo.toml index 3034a22a3..bd58614dc 100644 --- a/src/uu/rmdir/Cargo.toml +++ b/src/uu/rmdir/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_rmdir" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "rmdir ~ (uutils) remove empty DIRECTORY" @@ -15,7 +15,7 @@ edition = "2018" path = "src/rmdir.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } libc = "0.2.42" diff --git a/src/uu/rmdir/src/rmdir.rs b/src/uu/rmdir/src/rmdir.rs index f982cf4c3..f6da7ae7c 100644 --- a/src/uu/rmdir/src/rmdir.rs +++ b/src/uu/rmdir/src/rmdir.rs @@ -33,7 +33,7 @@ fn usage() -> String { pub fn uumain(args: impl uucore::Args) -> UResult<()> { 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 opts = Opts { ignore: matches.is_present(OPT_IGNORE_FAIL_NON_EMPTY), @@ -175,35 +175,31 @@ struct Opts { verbose: bool, } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(OPT_IGNORE_FAIL_NON_EMPTY) + Arg::new(OPT_IGNORE_FAIL_NON_EMPTY) .long(OPT_IGNORE_FAIL_NON_EMPTY) .help("ignore each failure that is solely because a directory is non-empty"), ) - .arg( - Arg::with_name(OPT_PARENTS) - .short("p") - .long(OPT_PARENTS) - .help( - "remove DIRECTORY and its ancestors; e.g., + .arg(Arg::new(OPT_PARENTS).short('p').long(OPT_PARENTS).help( + "remove DIRECTORY and its ancestors; e.g., 'rmdir -p a/b/c' is similar to rmdir a/b/c a/b a", - ), - ) + )) .arg( - Arg::with_name(OPT_VERBOSE) - .short("v") + Arg::new(OPT_VERBOSE) + .short('v') .long(OPT_VERBOSE) .help("output a diagnostic for every directory processed"), ) .arg( - Arg::with_name(ARG_DIRS) - .multiple(true) + Arg::new(ARG_DIRS) + .multiple_occurrences(true) .takes_value(true) .min_values(1) - .required(true), + .required(true) + .allow_invalid_utf8(true), ) } diff --git a/src/uu/runcon/Cargo.toml b/src/uu/runcon/Cargo.toml index ec9e7428f..3c651bb66 100644 --- a/src/uu/runcon/Cargo.toml +++ b/src/uu/runcon/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_runcon" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "runcon ~ (uutils) run command with specified security context" @@ -14,7 +14,7 @@ edition = "2018" path = "src/runcon.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version = ">=0.0.9", package="uucore", path="../../uucore", features=["entries", "fs", "perms"] } uucore_procs = { version = ">=0.0.6", package="uucore_procs", path="../../uucore_procs" } selinux = { version = "0.2" } diff --git a/src/uu/runcon/src/runcon.rs b/src/uu/runcon/src/runcon.rs index 595cf3e65..ede324ede 100644 --- a/src/uu/runcon/src/runcon.rs +++ b/src/uu/runcon/src/runcon.rs @@ -48,14 +48,14 @@ fn get_usage() -> String { pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = get_usage(); - let config = uu_app().usage(usage.as_ref()); + let config = uu_app().override_usage(usage.as_ref()); let options = match parse_command_line(config, args) { Ok(r) => r, Err(r) => { if let Error::CommandLine(ref r) = r { match r.kind { - clap::ErrorKind::HelpDisplayed | clap::ErrorKind::VersionDisplayed => { + clap::ErrorKind::DisplayHelp | clap::ErrorKind::DisplayVersion => { println!("{}", r); return Ok(()); } @@ -109,51 +109,59 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(VERSION) .about(ABOUT) .after_help(DESCRIPTION) .arg( - Arg::with_name(options::COMPUTE) - .short("c") + Arg::new(options::COMPUTE) + .short('c') .long(options::COMPUTE) .takes_value(false) .help("Compute process transition context before modifying."), ) .arg( - Arg::with_name(options::USER) - .short("u") + Arg::new(options::USER) + .short('u') .long(options::USER) .takes_value(true) .value_name("USER") - .help("Set user USER in the target security context."), + .help("Set user USER in the target security context.") + .allow_invalid_utf8(true), ) .arg( - Arg::with_name(options::ROLE) - .short("r") + Arg::new(options::ROLE) + .short('r') .long(options::ROLE) .takes_value(true) .value_name("ROLE") - .help("Set role ROLE in the target security context."), + .help("Set role ROLE in the target security context.") + .allow_invalid_utf8(true), ) .arg( - Arg::with_name(options::TYPE) - .short("t") + Arg::new(options::TYPE) + .short('t') .long(options::TYPE) .takes_value(true) .value_name("TYPE") - .help("Set type TYPE in the target security context."), + .help("Set type TYPE in the target security context.") + .allow_invalid_utf8(true), ) .arg( - Arg::with_name(options::RANGE) - .short("l") + Arg::new(options::RANGE) + .short('l') .long(options::RANGE) .takes_value(true) .value_name("RANGE") - .help("Set range RANGE in the target security context."), + .help("Set range RANGE in the target security context.") + .allow_invalid_utf8(true), + ) + .arg( + Arg::new("ARG") + .multiple_occurrences(true) + .allow_invalid_utf8(true), ) - .arg(Arg::with_name("ARG").multiple(true)) // Once "ARG" is parsed, everything after that belongs to it. // // This is not how POSIX does things, but this is how the GNU implementation @@ -202,7 +210,7 @@ struct Options { } fn parse_command_line(config: App, args: impl uucore::Args) -> Result { - let matches = config.get_matches_from_safe(args)?; + let matches = config.try_get_matches_from(args)?; let compute_transition_context = matches.is_present(options::COMPUTE); diff --git a/src/uu/seq/Cargo.toml b/src/uu/seq/Cargo.toml index c89da88b5..ba446a3ec 100644 --- a/src/uu/seq/Cargo.toml +++ b/src/uu/seq/Cargo.toml @@ -1,7 +1,7 @@ # spell-checker:ignore bigdecimal [package] name = "uu_seq" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "seq ~ (uutils) display a sequence of numbers" @@ -17,7 +17,7 @@ path = "src/seq.rs" [dependencies] bigdecimal = "0.3" -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } num-bigint = "0.4.0" num-traits = "0.2.14" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/seq/src/seq.rs b/src/uu/seq/src/seq.rs index 556ef9a6d..0e621197e 100644 --- a/src/uu/seq/src/seq.rs +++ b/src/uu/seq/src/seq.rs @@ -58,7 +58,7 @@ type RangeFloat = (ExtendedBigDecimal, ExtendedBigDecimal, ExtendedBigDecimal); #[uucore_procs::gen_uumain] pub fn uumain(args: impl uucore::Args) -> UResult<()> { 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 numbers = matches.values_of(ARG_NUMBERS).unwrap().collect::>(); @@ -137,38 +137,38 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) - .setting(AppSettings::AllowLeadingHyphen) + .setting(AppSettings::TrailingVarArg) + .setting(AppSettings::AllowHyphenValues) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(OPT_SEPARATOR) - .short("s") + Arg::new(OPT_SEPARATOR) + .short('s') .long("separator") .help("Separator character (defaults to \\n)") .takes_value(true) .number_of_values(1), ) .arg( - Arg::with_name(OPT_TERMINATOR) - .short("t") + Arg::new(OPT_TERMINATOR) + .short('t') .long("terminator") .help("Terminator character (defaults to \\n)") .takes_value(true) .number_of_values(1), ) .arg( - Arg::with_name(OPT_WIDTHS) - .short("w") + Arg::new(OPT_WIDTHS) + .short('w') .long("widths") .help("Equalize widths of all numbers by padding with zeros"), ) .arg( - Arg::with_name(ARG_NUMBERS) - .multiple(true) + Arg::new(ARG_NUMBERS) + .multiple_occurrences(true) .takes_value(true) - .allow_hyphen_values(true) .max_values(3) .required(true), ) diff --git a/src/uu/shred/Cargo.toml b/src/uu/shred/Cargo.toml index eab59b230..6b28f1242 100644 --- a/src/uu/shred/Cargo.toml +++ b/src/uu/shred/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_shred" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "shred ~ (uutils) hide former FILE contents with repeated overwrites" @@ -15,7 +15,7 @@ edition = "2018" path = "src/shred.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" rand = "0.7" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/shred/src/shred.rs b/src/uu/shred/src/shred.rs index f745c3bf6..c63f2c379 100644 --- a/src/uu/shred/src/shred.rs +++ b/src/uu/shred/src/shred.rs @@ -275,7 +275,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); - let app = uu_app().usage(&usage[..]); + let app = uu_app().override_usage(&usage[..]); let matches = app.get_matches_from(args); @@ -321,62 +321,66 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .after_help(AFTER_HELP) .arg( - Arg::with_name(options::FORCE) + Arg::new(options::FORCE) .long(options::FORCE) - .short("f") + .short('f') .help("change permissions to allow writing if necessary"), ) .arg( - Arg::with_name(options::ITERATIONS) + Arg::new(options::ITERATIONS) .long(options::ITERATIONS) - .short("n") + .short('n') .help("overwrite N times instead of the default (3)") .value_name("NUMBER") .default_value("3"), ) .arg( - Arg::with_name(options::SIZE) + Arg::new(options::SIZE) .long(options::SIZE) - .short("s") + .short('s') .takes_value(true) .value_name("N") .help("shred this many bytes (suffixes like K, M, G accepted)"), ) .arg( - Arg::with_name(options::REMOVE) - .short("u") + Arg::new(options::REMOVE) + .short('u') .long(options::REMOVE) .help("truncate and remove file after overwriting; See below"), ) .arg( - Arg::with_name(options::VERBOSE) + Arg::new(options::VERBOSE) .long(options::VERBOSE) - .short("v") + .short('v') .help("show progress"), ) .arg( - Arg::with_name(options::EXACT) + Arg::new(options::EXACT) .long(options::EXACT) - .short("x") + .short('x') .help( "do not round file sizes up to the next full block;\n\ this is the default for non-regular files", ), ) .arg( - Arg::with_name(options::ZERO) + Arg::new(options::ZERO) .long(options::ZERO) - .short("z") + .short('z') .help("add a final overwrite with zeros to hide shredding"), ) // Positional arguments - .arg(Arg::with_name(options::FILE).hidden(true).multiple(true)) + .arg( + Arg::new(options::FILE) + .hide(true) + .multiple_occurrences(true), + ) } // TODO: Add support for all postfixes here up to and including EiB diff --git a/src/uu/shuf/Cargo.toml b/src/uu/shuf/Cargo.toml index d9b8f7254..d750e9c8e 100644 --- a/src/uu/shuf/Cargo.toml +++ b/src/uu/shuf/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_shuf" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "shuf ~ (uutils) display random permutations of input lines" @@ -15,7 +15,7 @@ edition = "2018" path = "src/shuf.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } rand = "0.5" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/shuf/src/shuf.rs b/src/uu/shuf/src/shuf.rs index ce0af5ec2..c1090e5ff 100644 --- a/src/uu/shuf/src/shuf.rs +++ b/src/uu/shuf/src/shuf.rs @@ -29,7 +29,7 @@ Write a random permutation of the input lines to standard output. With no FILE, or when FILE is -, read standard input. "#; -static TEMPLATE: &str = "Usage: {usage}\nMandatory arguments to long options are mandatory for short options too.\n{unified}"; +static TEMPLATE: &str = "Usage: {usage}\nMandatory arguments to long options are mandatory for short options too.\n{options}"; struct Options { head_count: usize, @@ -116,27 +116,27 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .name(NAME) .version(crate_version!()) - .template(TEMPLATE) - .usage(USAGE) + .help_template(TEMPLATE) + .override_usage(USAGE) .arg( - Arg::with_name(options::ECHO) - .short("e") + Arg::new(options::ECHO) + .short('e') .long(options::ECHO) .takes_value(true) .value_name("ARG") .help("treat each ARG as an input line") - .multiple(true) + .multiple_occurrences(true) .use_delimiter(false) .min_values(0) .conflicts_with(options::INPUT_RANGE), ) .arg( - Arg::with_name(options::INPUT_RANGE) - .short("i") + Arg::new(options::INPUT_RANGE) + .short('i') .long(options::INPUT_RANGE) .takes_value(true) .value_name("LO-HI") @@ -144,41 +144,41 @@ pub fn uu_app() -> App<'static, 'static> { .conflicts_with(options::FILE), ) .arg( - Arg::with_name(options::HEAD_COUNT) - .short("n") + Arg::new(options::HEAD_COUNT) + .short('n') .long(options::HEAD_COUNT) .takes_value(true) .value_name("COUNT") .help("output at most COUNT lines"), ) .arg( - Arg::with_name(options::OUTPUT) - .short("o") + Arg::new(options::OUTPUT) + .short('o') .long(options::OUTPUT) .takes_value(true) .value_name("FILE") .help("write result to FILE instead of standard output"), ) .arg( - Arg::with_name(options::RANDOM_SOURCE) + Arg::new(options::RANDOM_SOURCE) .long(options::RANDOM_SOURCE) .takes_value(true) .value_name("FILE") .help("get random bytes from FILE"), ) .arg( - Arg::with_name(options::REPEAT) - .short("r") + Arg::new(options::REPEAT) + .short('r') .long(options::REPEAT) .help("output lines can be repeated"), ) .arg( - Arg::with_name(options::ZERO_TERMINATED) - .short("z") + Arg::new(options::ZERO_TERMINATED) + .short('z') .long(options::ZERO_TERMINATED) .help("line delimiter is NUL, not newline"), ) - .arg(Arg::with_name(options::FILE).takes_value(true)) + .arg(Arg::new(options::FILE).takes_value(true)) } fn read_input_file(filename: &str) -> UResult> { diff --git a/src/uu/sleep/Cargo.toml b/src/uu/sleep/Cargo.toml index 0df5b5a4a..3c9167e51 100644 --- a/src/uu/sleep/Cargo.toml +++ b/src/uu/sleep/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_sleep" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "sleep ~ (uutils) pause for DURATION" @@ -15,7 +15,7 @@ edition = "2018" path = "src/sleep.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/sleep/src/sleep.rs b/src/uu/sleep/src/sleep.rs index 80e8cd852..230516bb9 100644 --- a/src/uu/sleep/src/sleep.rs +++ b/src/uu/sleep/src/sleep.rs @@ -35,7 +35,7 @@ fn usage() -> String { pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); - let matches = uu_app().usage(&usage[..]).get_matches_from(args); + let matches = uu_app().override_usage(&usage[..]).get_matches_from(args); if let Some(values) = matches.values_of(options::NUMBER) { let numbers = values.collect(); @@ -45,18 +45,17 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .after_help(LONG_HELP) .arg( - Arg::with_name(options::NUMBER) - .long(options::NUMBER) + Arg::new(options::NUMBER) .help("pause for NUMBER seconds") .value_name(options::NUMBER) .index(1) - .multiple(true) + .multiple_occurrences(true) .required(true), ) } diff --git a/src/uu/sort/Cargo.toml b/src/uu/sort/Cargo.toml index 95e71c4bc..b21c76e82 100644 --- a/src/uu/sort/Cargo.toml +++ b/src/uu/sort/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_sort" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "sort ~ (uutils) sort input lines" @@ -16,7 +16,7 @@ path = "src/sort.rs" [dependencies] binary-heap-plus = "0.4.1" -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } compare = "0.1.0" ctrlc = { version = "3.0", features = ["termination"] } fnv = "1.0.7" diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs index ae1bcfa4c..47c0cc085 100644 --- a/src/uu/sort/src/sort.rs +++ b/src/uu/sort/src/sort.rs @@ -1046,8 +1046,8 @@ With no FILE, or when FILE is -, read standard input.", } /// Creates an `Arg` that conflicts with all other sort modes. -fn make_sort_mode_arg<'a, 'b>(mode: &'a str, short: &'b str, help: &'b str) -> Arg<'a, 'b> { - let mut arg = Arg::with_name(mode).short(short).long(mode).help(help); +fn make_sort_mode_arg<'a>(mode: &'a str, short: char, help: &'a str) -> Arg<'a> { + let mut arg = Arg::new(mode).short(short).long(mode).help(help); for possible_mode in &options::modes::ALL_SORT_MODES { if *possible_mode != mode { arg = arg.conflicts_with(possible_mode); @@ -1064,7 +1064,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); let mut settings: GlobalSettings = Default::default(); - let matches = match uu_app().usage(&usage[..]).get_matches_from_safe(args) { + let matches = match uu_app() + .override_usage(&usage[..]) + .try_get_matches_from(args) + { Ok(t) => t, Err(e) => { // not all clap "Errors" are because of a failure to parse arguments. @@ -1072,11 +1075,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { // nor return with a non-zero exit code in this case (we should print to stdout and return 0). // This logic is similar to the code in clap, but we return 2 as the exit code in case of real failure // (clap returns 1). + e.print().unwrap(); if e.use_stderr() { - eprintln!("{}", e.message); set_exit_code(2); - } else { - println!("{}", e.message); } return Ok(()); } @@ -1209,11 +1210,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { )); } - if let Some(arg) = matches.args.get(options::SEPARATOR) { - let mut separator = arg.vals[0].to_str().ok_or_else(|| { + if let Some(arg) = matches.value_of_os(options::SEPARATOR) { + let mut separator = arg.to_str().ok_or_else(|| { UUsageError::new( 2, - format!("separator is not valid unicode: {}", arg.vals[0].quote()), + format!("separator is not valid unicode: {}", arg.quote()), ) })?; if separator == "\\0" { @@ -1276,12 +1277,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { exec(&mut files, &settings, output, &mut tmp_dir) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(options::modes::SORT) + Arg::new(options::modes::SORT) .long(options::modes::SORT) .takes_value(true) .possible_values(&[ @@ -1296,37 +1297,37 @@ pub fn uu_app() -> App<'static, 'static> { ) .arg(make_sort_mode_arg( options::modes::HUMAN_NUMERIC, - "h", + 'h', "compare according to human readable sizes, eg 1M > 100k", )) .arg(make_sort_mode_arg( options::modes::MONTH, - "M", + 'M', "compare according to month name abbreviation", )) .arg(make_sort_mode_arg( options::modes::NUMERIC, - "n", + 'n', "compare according to string numerical value", )) .arg(make_sort_mode_arg( options::modes::GENERAL_NUMERIC, - "g", + 'g', "compare according to string general numerical value", )) .arg(make_sort_mode_arg( options::modes::VERSION, - "V", + 'V', "Sort by SemVer version number, eg 1.12.2 > 1.1.2", )) .arg(make_sort_mode_arg( options::modes::RANDOM, - "R", + 'R', "shuffle in random order", )) .arg( - Arg::with_name(options::DICTIONARY_ORDER) - .short("d") + Arg::new(options::DICTIONARY_ORDER) + .short('d') .long(options::DICTIONARY_ORDER) .help("consider only blanks and alphanumeric characters") .conflicts_with_all(&[ @@ -1337,14 +1338,14 @@ pub fn uu_app() -> App<'static, 'static> { ]), ) .arg( - Arg::with_name(options::MERGE) - .short("m") + Arg::new(options::MERGE) + .short('m') .long(options::MERGE) .help("merge already sorted files; do not sort"), ) .arg( - Arg::with_name(options::check::CHECK) - .short("c") + Arg::new(options::check::CHECK) + .short('c') .long(options::check::CHECK) .takes_value(true) .require_equals(true) @@ -1358,8 +1359,8 @@ pub fn uu_app() -> App<'static, 'static> { .help("check for sorted input; do not sort"), ) .arg( - Arg::with_name(options::check::CHECK_SILENT) - .short("C") + Arg::new(options::check::CHECK_SILENT) + .short('C') .long(options::check::CHECK_SILENT) .conflicts_with(options::OUTPUT) .help( @@ -1368,14 +1369,14 @@ pub fn uu_app() -> App<'static, 'static> { ), ) .arg( - Arg::with_name(options::IGNORE_CASE) - .short("f") + Arg::new(options::IGNORE_CASE) + .short('f') .long(options::IGNORE_CASE) .help("fold lower case to upper case characters"), ) .arg( - Arg::with_name(options::IGNORE_NONPRINTING) - .short("i") + Arg::new(options::IGNORE_NONPRINTING) + .short('i') .long(options::IGNORE_NONPRINTING) .help("ignore nonprinting characters") .conflicts_with_all(&[ @@ -1386,113 +1387,116 @@ pub fn uu_app() -> App<'static, 'static> { ]), ) .arg( - Arg::with_name(options::IGNORE_LEADING_BLANKS) - .short("b") + Arg::new(options::IGNORE_LEADING_BLANKS) + .short('b') .long(options::IGNORE_LEADING_BLANKS) .help("ignore leading blanks when finding sort keys in each line"), ) .arg( - Arg::with_name(options::OUTPUT) - .short("o") + Arg::new(options::OUTPUT) + .short('o') .long(options::OUTPUT) .help("write output to FILENAME instead of stdout") .takes_value(true) .value_name("FILENAME"), ) .arg( - Arg::with_name(options::REVERSE) - .short("r") + Arg::new(options::REVERSE) + .short('r') .long(options::REVERSE) .help("reverse the output"), ) .arg( - Arg::with_name(options::STABLE) - .short("s") + Arg::new(options::STABLE) + .short('s') .long(options::STABLE) .help("stabilize sort by disabling last-resort comparison"), ) .arg( - Arg::with_name(options::UNIQUE) - .short("u") + Arg::new(options::UNIQUE) + .short('u') .long(options::UNIQUE) .help("output only the first of an equal run"), ) .arg( - Arg::with_name(options::KEY) - .short("k") + Arg::new(options::KEY) + .short('k') .long(options::KEY) .help("sort by a key") .long_help(LONG_HELP_KEYS) - .multiple(true) + .multiple_occurrences(true) .number_of_values(1) .takes_value(true), ) .arg( - Arg::with_name(options::SEPARATOR) - .short("t") + Arg::new(options::SEPARATOR) + .short('t') .long(options::SEPARATOR) .help("custom separator for -k") - .takes_value(true), + .takes_value(true) + .allow_invalid_utf8(true), ) .arg( - Arg::with_name(options::ZERO_TERMINATED) - .short("z") + Arg::new(options::ZERO_TERMINATED) + .short('z') .long(options::ZERO_TERMINATED) .help("line delimiter is NUL, not newline"), ) .arg( - Arg::with_name(options::PARALLEL) + Arg::new(options::PARALLEL) .long(options::PARALLEL) .help("change the number of threads running concurrently to NUM_THREADS") .takes_value(true) .value_name("NUM_THREADS"), ) .arg( - Arg::with_name(options::BUF_SIZE) - .short("S") + Arg::new(options::BUF_SIZE) + .short('S') .long(options::BUF_SIZE) .help("sets the maximum SIZE of each segment in number of sorted items") .takes_value(true) .value_name("SIZE"), ) .arg( - Arg::with_name(options::TMP_DIR) - .short("T") + Arg::new(options::TMP_DIR) + .short('T') .long(options::TMP_DIR) .help("use DIR for temporaries, not $TMPDIR or /tmp") .takes_value(true) .value_name("DIR"), ) .arg( - Arg::with_name(options::COMPRESS_PROG) + Arg::new(options::COMPRESS_PROG) .long(options::COMPRESS_PROG) .help("compress temporary files with PROG, decompress with PROG -d") .long_help("PROG has to take input from stdin and output to stdout") .value_name("PROG"), ) .arg( - Arg::with_name(options::BATCH_SIZE) + Arg::new(options::BATCH_SIZE) .long(options::BATCH_SIZE) .help("Merge at most N_MERGE inputs at once.") .value_name("N_MERGE"), ) .arg( - Arg::with_name(options::FILES0_FROM) + Arg::new(options::FILES0_FROM) .long(options::FILES0_FROM) .help("read input from the files specified by NUL-terminated NUL_FILES") .takes_value(true) .value_name("NUL_FILES") - .multiple(true), + .multiple_occurrences(true) + .allow_invalid_utf8(true), ) .arg( - Arg::with_name(options::DEBUG) + Arg::new(options::DEBUG) .long(options::DEBUG) .help("underline the parts of the line that are actually used for sorting"), ) .arg( - Arg::with_name(options::FILES) - .multiple(true) - .takes_value(true), + Arg::new(options::FILES) + .multiple_occurrences(true) + .takes_value(true) + .allow_invalid_utf8(true), ) } diff --git a/src/uu/split/Cargo.toml b/src/uu/split/Cargo.toml index a3b28f072..447e28f6a 100644 --- a/src/uu/split/Cargo.toml +++ b/src/uu/split/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_split" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "split ~ (uutils) split input into output files" @@ -15,7 +15,7 @@ edition = "2018" path = "src/split.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index 04ee3641c..6a0576197 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -59,7 +59,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let long_usage = get_long_usage(); let matches = uu_app() - .usage(&usage[..]) + .override_usage(&usage[..]) .after_help(&long_usage[..]) .get_matches_from(args); @@ -103,29 +103,29 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { split(settings) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about("Create output files containing consecutive or interleaved sections of input") // strategy (mutually exclusive) .arg( - Arg::with_name(OPT_BYTES) - .short("b") + Arg::new(OPT_BYTES) + .short('b') .long(OPT_BYTES) .takes_value(true) .help("put SIZE bytes per output file"), ) .arg( - Arg::with_name(OPT_LINE_BYTES) - .short("C") + Arg::new(OPT_LINE_BYTES) + .short('C') .long(OPT_LINE_BYTES) .takes_value(true) .default_value("2") .help("put at most SIZE bytes of lines per output file"), ) .arg( - Arg::with_name(OPT_LINES) - .short("l") + Arg::new(OPT_LINES) + .short('l') .long(OPT_LINES) .takes_value(true) .default_value("1000") @@ -133,50 +133,52 @@ pub fn uu_app() -> App<'static, 'static> { ) // rest of the arguments .arg( - Arg::with_name(OPT_ADDITIONAL_SUFFIX) + Arg::new(OPT_ADDITIONAL_SUFFIX) .long(OPT_ADDITIONAL_SUFFIX) .takes_value(true) .default_value("") .help("additional suffix to append to output file names"), ) .arg( - Arg::with_name(OPT_FILTER) + Arg::new(OPT_FILTER) .long(OPT_FILTER) .takes_value(true) - .help("write to shell COMMAND file name is $FILE (Currently not implemented for Windows)"), + .help( + "write to shell COMMAND file name is $FILE (Currently not implemented for Windows)", + ), ) .arg( - Arg::with_name(OPT_NUMERIC_SUFFIXES) - .short("d") + Arg::new(OPT_NUMERIC_SUFFIXES) + .short('d') .long(OPT_NUMERIC_SUFFIXES) .takes_value(true) - .default_value("0") + .default_missing_value("0") .help("use numeric suffixes instead of alphabetic"), ) .arg( - Arg::with_name(OPT_SUFFIX_LENGTH) - .short("a") + Arg::new(OPT_SUFFIX_LENGTH) + .short('a') .long(OPT_SUFFIX_LENGTH) .takes_value(true) .default_value(OPT_DEFAULT_SUFFIX_LENGTH) .help("use suffixes of length N (default 2)"), ) .arg( - Arg::with_name(OPT_VERBOSE) + Arg::new(OPT_VERBOSE) .long(OPT_VERBOSE) .help("print a diagnostic just before each output file is opened"), ) .arg( - Arg::with_name(ARG_INPUT) - .takes_value(true) - .default_value("-") - .index(1) + Arg::new(ARG_INPUT) + .takes_value(true) + .default_value("-") + .index(1), ) .arg( - Arg::with_name(ARG_PREFIX) - .takes_value(true) - .default_value("x") - .index(2) + Arg::new(ARG_PREFIX) + .takes_value(true) + .default_value("x") + .index(2), ) } diff --git a/src/uu/stat/Cargo.toml b/src/uu/stat/Cargo.toml index a2a7275eb..08735d426 100644 --- a/src/uu/stat/Cargo.toml +++ b/src/uu/stat/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_stat" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "stat ~ (uutils) display FILE status" @@ -15,7 +15,7 @@ edition = "2018" path = "src/stat.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "libc", "fs", "fsext"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/stat/src/stat.rs b/src/uu/stat/src/stat.rs index 916acc041..604ae33c8 100644 --- a/src/uu/stat/src/stat.rs +++ b/src/uu/stat/src/stat.rs @@ -953,7 +953,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let long_usage = get_long_usage(); let matches = uu_app() - .usage(&usage[..]) + .override_usage(&usage[..]) .after_help(&long_usage[..]) .get_matches_from(args); @@ -966,31 +966,31 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(options::DEREFERENCE) - .short("L") + Arg::new(options::DEREFERENCE) + .short('L') .long(options::DEREFERENCE) .help("follow links"), ) .arg( - Arg::with_name(options::FILE_SYSTEM) - .short("f") + Arg::new(options::FILE_SYSTEM) + .short('f') .long(options::FILE_SYSTEM) .help("display file system status instead of file status"), ) .arg( - Arg::with_name(options::TERSE) - .short("t") + Arg::new(options::TERSE) + .short('t') .long(options::TERSE) .help("print the information in terse form"), ) .arg( - Arg::with_name(options::FORMAT) - .short("c") + Arg::new(options::FORMAT) + .short('c') .long(options::FORMAT) .help( "use the specified FORMAT instead of the default; @@ -999,7 +999,7 @@ pub fn uu_app() -> App<'static, 'static> { .value_name("FORMAT"), ) .arg( - Arg::with_name(options::PRINTF) + Arg::new(options::PRINTF) .long(options::PRINTF) .value_name("FORMAT") .help( @@ -1009,8 +1009,8 @@ pub fn uu_app() -> App<'static, 'static> { ), ) .arg( - Arg::with_name(ARG_FILES) - .multiple(true) + Arg::new(ARG_FILES) + .multiple_occurrences(true) .takes_value(true) .min_values(1), ) diff --git a/src/uu/stdbuf/Cargo.toml b/src/uu/stdbuf/Cargo.toml index d116cb4a7..919ce99fa 100644 --- a/src/uu/stdbuf/Cargo.toml +++ b/src/uu/stdbuf/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_stdbuf" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "stdbuf ~ (uutils) run COMMAND with modified standard stream buffering" @@ -15,13 +15,13 @@ edition = "2018" path = "src/stdbuf.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } tempfile = "3.1" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [build-dependencies] -libstdbuf = { version="0.0.9", package="uu_stdbuf_libstdbuf", path="src/libstdbuf" } +libstdbuf = { version="0.0.12", package="uu_stdbuf_libstdbuf", path="src/libstdbuf" } [[bin]] name = "stdbuf" diff --git a/src/uu/stdbuf/src/libstdbuf/Cargo.toml b/src/uu/stdbuf/src/libstdbuf/Cargo.toml index 71ef95c4c..4e35a9438 100644 --- a/src/uu/stdbuf/src/libstdbuf/Cargo.toml +++ b/src/uu/stdbuf/src/libstdbuf/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_stdbuf_libstdbuf" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "stdbuf/libstdbuf ~ (uutils); dynamic library required for stdbuf" diff --git a/src/uu/stdbuf/src/stdbuf.rs b/src/uu/stdbuf/src/stdbuf.rs index b5093cc01..ca8229c97 100644 --- a/src/uu/stdbuf/src/stdbuf.rs +++ b/src/uu/stdbuf/src/stdbuf.rs @@ -40,11 +40,11 @@ static LONG_HELP: &str = "If MODE is 'L' the corresponding stream will be line b mod options { pub const INPUT: &str = "input"; - pub const INPUT_SHORT: &str = "i"; + pub const INPUT_SHORT: char = 'i'; pub const OUTPUT: &str = "output"; - pub const OUTPUT_SHORT: &str = "o"; + pub const OUTPUT_SHORT: char = 'o'; pub const ERROR: &str = "error"; - pub const ERROR_SHORT: &str = "e"; + pub const ERROR_SHORT: char = 'e'; pub const COMMAND: &str = "command"; } @@ -66,7 +66,7 @@ struct ProgramOptions { stderr: BufferType, } -impl<'a> TryFrom<&ArgMatches<'a>> for ProgramOptions { +impl<'a> TryFrom<&ArgMatches> for ProgramOptions { type Error = ProgramOptionsError; fn try_from(matches: &ArgMatches) -> Result { @@ -156,7 +156,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { .accept_any(); 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 options = ProgramOptions::try_from(&matches).map_err(|e| UUsageError::new(125, e.0))?; @@ -191,41 +191,41 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .after_help(LONG_HELP) .setting(AppSettings::TrailingVarArg) .arg( - Arg::with_name(options::INPUT) + Arg::new(options::INPUT) .long(options::INPUT) .short(options::INPUT_SHORT) .help("adjust standard input stream buffering") .value_name("MODE") - .required_unless_one(&[options::OUTPUT, options::ERROR]), + .required_unless_present_any(&[options::OUTPUT, options::ERROR]), ) .arg( - Arg::with_name(options::OUTPUT) + Arg::new(options::OUTPUT) .long(options::OUTPUT) .short(options::OUTPUT_SHORT) .help("adjust standard output stream buffering") .value_name("MODE") - .required_unless_one(&[options::INPUT, options::ERROR]), + .required_unless_present_any(&[options::INPUT, options::ERROR]), ) .arg( - Arg::with_name(options::ERROR) + Arg::new(options::ERROR) .long(options::ERROR) .short(options::ERROR_SHORT) .help("adjust standard error stream buffering") .value_name("MODE") - .required_unless_one(&[options::INPUT, options::OUTPUT]), + .required_unless_present_any(&[options::INPUT, options::OUTPUT]), ) .arg( - Arg::with_name(options::COMMAND) - .multiple(true) + Arg::new(options::COMMAND) + .multiple_occurrences(true) .takes_value(true) - .hidden(true) + .hide(true) .required(true), ) } diff --git a/src/uu/sum/Cargo.toml b/src/uu/sum/Cargo.toml index b09dd4fc6..d8d077740 100644 --- a/src/uu/sum/Cargo.toml +++ b/src/uu/sum/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_sum" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "sum ~ (uutils) display checksum and block counts for input" @@ -15,7 +15,7 @@ edition = "2018" path = "src/sum.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/sum/src/sum.rs b/src/uu/sum/src/sum.rs index bcc4738e8..67bff31b0 100644 --- a/src/uu/sum/src/sum.rs +++ b/src/uu/sum/src/sum.rs @@ -140,21 +140,25 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .name(NAME) .version(crate_version!()) - .usage(USAGE) + .override_usage(USAGE) .about(SUMMARY) - .arg(Arg::with_name(options::FILE).multiple(true).hidden(true)) .arg( - Arg::with_name(options::BSD_COMPATIBLE) - .short(options::BSD_COMPATIBLE) + Arg::new(options::FILE) + .multiple_occurrences(true) + .hide(true), + ) + .arg( + Arg::new(options::BSD_COMPATIBLE) + .short('r') .help("use the BSD sum algorithm, use 1K blocks (default)"), ) .arg( - Arg::with_name(options::SYSTEM_V_COMPATIBLE) - .short("s") + Arg::new(options::SYSTEM_V_COMPATIBLE) + .short('s') .long(options::SYSTEM_V_COMPATIBLE) .help("use System V sum algorithm, use 512 bytes blocks"), ) diff --git a/src/uu/sync/Cargo.toml b/src/uu/sync/Cargo.toml index 161b5af62..e61000029 100644 --- a/src/uu/sync/Cargo.toml +++ b/src/uu/sync/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_sync" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "sync ~ (uutils) synchronize cache writes to storage" @@ -15,7 +15,7 @@ edition = "2018" path = "src/sync.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["wide"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/sync/src/sync.rs b/src/uu/sync/src/sync.rs index 4e6bb7d27..c6416ce5b 100644 --- a/src/uu/sync/src/sync.rs +++ b/src/uu/sync/src/sync.rs @@ -165,7 +165,7 @@ fn usage() -> String { pub fn uumain(args: impl uucore::Args) -> UResult<()> { 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 files: Vec = matches .values_of(ARG_FILES) @@ -194,25 +194,29 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(options::FILE_SYSTEM) - .short("f") + Arg::new(options::FILE_SYSTEM) + .short('f') .long(options::FILE_SYSTEM) .conflicts_with(options::DATA) .help("sync the file systems that contain the files (Linux and Windows only)"), ) .arg( - Arg::with_name(options::DATA) - .short("d") + Arg::new(options::DATA) + .short('d') .long(options::DATA) .conflicts_with(options::FILE_SYSTEM) .help("sync only file data, no unneeded metadata (Linux only)"), ) - .arg(Arg::with_name(ARG_FILES).multiple(true).takes_value(true)) + .arg( + Arg::new(ARG_FILES) + .multiple_occurrences(true) + .takes_value(true), + ) } fn sync() -> isize { diff --git a/src/uu/tac/Cargo.toml b/src/uu/tac/Cargo.toml index 81ecfcd17..c23f4976d 100644 --- a/src/uu/tac/Cargo.toml +++ b/src/uu/tac/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "uu_tac" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "tac ~ (uutils) concatenate and display input lines in reverse order" @@ -20,7 +20,7 @@ path = "src/tac.rs" memchr = "2" memmap2 = "0.5" regex = "1" -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/tac/src/tac.rs b/src/uu/tac/src/tac.rs index 0a6599d7c..2285fcacc 100644 --- a/src/uu/tac/src/tac.rs +++ b/src/uu/tac/src/tac.rs @@ -60,34 +60,38 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { tac(files, before, regex, separator) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .name(NAME) .version(crate_version!()) - .usage(USAGE) + .override_usage(USAGE) .about(SUMMARY) .arg( - Arg::with_name(options::BEFORE) - .short("b") + Arg::new(options::BEFORE) + .short('b') .long(options::BEFORE) .help("attach the separator before instead of after") .takes_value(false), ) .arg( - Arg::with_name(options::REGEX) - .short("r") + Arg::new(options::REGEX) + .short('r') .long(options::REGEX) .help("interpret the sequence as a regular expression") .takes_value(false), ) .arg( - Arg::with_name(options::SEPARATOR) - .short("s") + Arg::new(options::SEPARATOR) + .short('s') .long(options::SEPARATOR) .help("use STRING as the separator instead of newline") .takes_value(true), ) - .arg(Arg::with_name(options::FILE).hidden(true).multiple(true)) + .arg( + Arg::new(options::FILE) + .hide(true) + .multiple_occurrences(true), + ) } /// Print lines of a buffer in reverse, with line separator given as a regex. diff --git a/src/uu/tail/Cargo.toml b/src/uu/tail/Cargo.toml index 987f42e3b..ab9d8647a 100644 --- a/src/uu/tail/Cargo.toml +++ b/src/uu/tail/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_tail" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "tail ~ (uutils) display the last lines of input" @@ -15,7 +15,7 @@ edition = "2018" path = "src/tail.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["ringbuffer"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/tail/src/lines.rs b/src/uu/tail/src/lines.rs new file mode 100644 index 000000000..6e472b32e --- /dev/null +++ b/src/uu/tail/src/lines.rs @@ -0,0 +1,83 @@ +// * This file is part of the uutils coreutils package. +// * +// * For the full copyright and license information, please view the LICENSE +// * file that was distributed with this source code. +//! Iterate over lines, including the line ending character(s). +//! +//! This module provides the [`lines`] function, similar to the +//! [`BufRead::lines`] method. While the [`BufRead::lines`] method +//! yields [`String`] instances that do not include the line ending +//! characters (`"\n"` or `"\r\n"`), our function yields [`String`] +//! instances that include the line ending characters. This is useful +//! if the input data does not end with a newline character and you +//! want to preserve the exact form of the input data. +use std::io::BufRead; + +/// Returns an iterator over the lines, including line ending characters. +/// +/// This function is just like [`BufRead::lines`], but it includes the +/// line ending characters in each yielded [`String`] if the input +/// data has them. +/// +/// # Examples +/// +/// If the input data does not end with a newline character (`'\n'`), +/// then the last [`String`] yielded by this iterator also does not +/// end with a newline: +/// +/// ```rust,ignore +/// use std::io::BufRead; +/// use std::io::Cursor; +/// +/// let cursor = Cursor::new(b"x\ny\nz"); +/// let mut it = cursor.lines(); +/// +/// assert_eq!(it.next(), Some(String::from("x\n"))); +/// assert_eq!(it.next(), Some(String::from("y\n"))); +/// assert_eq!(it.next(), Some(String::from("z"))); +/// assert_eq!(it.next(), None); +/// ``` +pub(crate) fn lines(reader: B) -> Lines +where + B: BufRead, +{ + Lines { buf: reader } +} + +/// An iterator over the lines of an instance of `BufRead`. +/// +/// This struct is generally created by calling [`lines`] on a `BufRead`. +/// Please see the documentation of [`lines`] for more details. +pub(crate) struct Lines { + buf: B, +} + +impl Iterator for Lines { + type Item = std::io::Result; + + fn next(&mut self) -> Option> { + let mut buf = String::new(); + match self.buf.read_line(&mut buf) { + Ok(0) => None, + Ok(_n) => Some(Ok(buf)), + Err(e) => Some(Err(e)), + } + } +} + +#[cfg(test)] +mod tests { + use crate::lines::lines; + use std::io::Cursor; + + #[test] + fn test_lines() { + let cursor = Cursor::new(b"x\ny\nz"); + let mut it = lines(cursor).map(|l| l.unwrap()); + + assert_eq!(it.next(), Some(String::from("x\n"))); + assert_eq!(it.next(), Some(String::from("y\n"))); + assert_eq!(it.next(), Some(String::from("z"))); + assert_eq!(it.next(), None); + } +} diff --git a/src/uu/tail/src/tail.rs b/src/uu/tail/src/tail.rs index 655abcecf..9ef69a77c 100644 --- a/src/uu/tail/src/tail.rs +++ b/src/uu/tail/src/tail.rs @@ -16,9 +16,11 @@ extern crate clap; extern crate uucore; mod chunks; +mod lines; mod parse; mod platform; use chunks::ReverseChunks; +use lines::lines; use clap::{App, Arg}; use std::collections::VecDeque; @@ -30,7 +32,7 @@ use std::path::Path; use std::thread::sleep; use std::time::Duration; use uucore::display::Quotable; -use uucore::error::{UResult, USimpleError}; +use uucore::error::{FromIo, UResult, USimpleError}; use uucore::parse_size::{parse_size, ParseSizeError}; use uucore::ringbuffer::RingBuffer; @@ -220,7 +222,8 @@ fn uu_tail(settings: &Settings) -> UResult<()> { if path.is_dir() { continue; } - let mut file = File::open(&path).unwrap(); + let mut file = File::open(&path) + .map_err_context(|| format!("cannot open {} for reading", filename.quote()))?; let md = file.metadata().unwrap(); if is_seekable(&mut file) && get_block_size(&md) > 0 { bounded_tail(&mut file, settings); @@ -271,14 +274,14 @@ fn arg_iterate<'a>( } } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) - .usage(USAGE) + .override_usage(USAGE) .arg( - Arg::with_name(options::BYTES) - .short("c") + Arg::new(options::BYTES) + .short('c') .long(options::BYTES) .takes_value(true) .allow_hyphen_values(true) @@ -286,14 +289,14 @@ pub fn uu_app() -> App<'static, 'static> { .help("Number of bytes to print"), ) .arg( - Arg::with_name(options::FOLLOW) - .short("f") + Arg::new(options::FOLLOW) + .short('f') .long(options::FOLLOW) .help("Print the file as it grows"), ) .arg( - Arg::with_name(options::LINES) - .short("n") + Arg::new(options::LINES) + .short('n') .long(options::LINES) .takes_value(true) .allow_hyphen_values(true) @@ -301,42 +304,42 @@ pub fn uu_app() -> App<'static, 'static> { .help("Number of lines to print"), ) .arg( - Arg::with_name(options::PID) + Arg::new(options::PID) .long(options::PID) .takes_value(true) .help("with -f, terminate after process ID, PID dies"), ) .arg( - Arg::with_name(options::verbosity::QUIET) - .short("q") + Arg::new(options::verbosity::QUIET) + .short('q') .long(options::verbosity::QUIET) .visible_alias("silent") .overrides_with_all(&[options::verbosity::QUIET, options::verbosity::VERBOSE]) .help("never output headers giving file names"), ) .arg( - Arg::with_name(options::SLEEP_INT) - .short("s") + Arg::new(options::SLEEP_INT) + .short('s') .takes_value(true) .long(options::SLEEP_INT) .help("Number or seconds to sleep between polling the file when running with -f"), ) .arg( - Arg::with_name(options::verbosity::VERBOSE) - .short("v") + Arg::new(options::verbosity::VERBOSE) + .short('v') .long(options::verbosity::VERBOSE) .overrides_with_all(&[options::verbosity::QUIET, options::verbosity::VERBOSE]) .help("always output headers giving file names"), ) .arg( - Arg::with_name(options::ZERO_TERM) - .short("z") + Arg::new(options::ZERO_TERM) + .short('z') .long(options::ZERO_TERM) .help("Line delimiter is NUL, not newline"), ) .arg( - Arg::with_name(options::ARG_FILES) - .multiple(true) + Arg::new(options::ARG_FILES) + .multiple_occurrences(true) .takes_value(true) .min_values(1), ) @@ -481,8 +484,8 @@ fn unbounded_tail(reader: &mut BufReader, settings: &Settings) -> UR // data in the ringbuf. match settings.mode { FilterMode::Lines(count, _) => { - for line in unbounded_tail_collect(reader.lines(), count, settings.beginning) { - println!("{}", line); + for line in unbounded_tail_collect(lines(reader), count, settings.beginning) { + print!("{}", line); } } FilterMode::Bytes(count) => { diff --git a/src/uu/tee/Cargo.toml b/src/uu/tee/Cargo.toml index b754b2bba..5e99cfc95 100644 --- a/src/uu/tee/Cargo.toml +++ b/src/uu/tee/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_tee" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "tee ~ (uutils) display input and copy to FILE" @@ -15,7 +15,7 @@ edition = "2018" path = "src/tee.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" retain_mut = "=0.1.2" # ToDO: [2021-01-01; rivy; maint/MinSRV] ~ v0.1.5 uses const generics which aren't stabilized until rust v1.51.0 uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["libc"] } diff --git a/src/uu/tee/src/tee.rs b/src/uu/tee/src/tee.rs index 9629e711d..5e26c6491 100644 --- a/src/uu/tee/src/tee.rs +++ b/src/uu/tee/src/tee.rs @@ -42,7 +42,7 @@ fn usage() -> String { pub fn uumain(args: impl uucore::Args) -> UResult<()> { 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 options = Options { append: matches.is_present(options::APPEND), @@ -59,24 +59,24 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .after_help("If a FILE is -, it refers to a file named - .") .arg( - Arg::with_name(options::APPEND) + Arg::new(options::APPEND) .long(options::APPEND) - .short("a") + .short('a') .help("append to the given FILEs, do not overwrite"), ) .arg( - Arg::with_name(options::IGNORE_INTERRUPTS) + Arg::new(options::IGNORE_INTERRUPTS) .long(options::IGNORE_INTERRUPTS) - .short("i") + .short('i') .help("ignore interrupt signals (ignored on non-Unix platforms)"), ) - .arg(Arg::with_name(options::FILE).multiple(true)) + .arg(Arg::new(options::FILE).multiple_occurrences(true)) } #[cfg(unix)] diff --git a/src/uu/test/Cargo.toml b/src/uu/test/Cargo.toml index 5fcc4f7cd..e8b3b7073 100644 --- a/src/uu/test/Cargo.toml +++ b/src/uu/test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_test" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "test ~ (uutils) evaluate comparison and file type expressions" @@ -15,7 +15,7 @@ edition = "2018" path = "src/test.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/test/src/test.rs b/src/uu/test/src/test.rs index 653161631..c2bd9d3d8 100644 --- a/src/uu/test/src/test.rs +++ b/src/uu/test/src/test.rs @@ -86,10 +86,10 @@ NOTE: your shell may have its own version of test and/or [, which usually supers the version described here. Please refer to your shell's documentation for details about the options it supports."; -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) - .setting(AppSettings::DisableHelpFlags) - .setting(AppSettings::DisableVersion) + .setting(AppSettings::DisableHelpFlag) + .setting(AppSettings::DisableVersionFlag) } #[uucore_procs::gen_uumain] @@ -104,12 +104,10 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> { // Let clap pretty-print help and version App::new(binary_name) .version(crate_version!()) - .usage(USAGE) + .override_usage(USAGE) .after_help(AFTER_HELP) // Disable printing of -h and -v as valid alternatives for --help and --version, // since we don't recognize -h and -v as help/version flags. - .setting(AppSettings::NeedsLongHelp) - .setting(AppSettings::NeedsLongVersion) .get_matches_from(std::iter::once(program).chain(args.into_iter())); return Ok(()); } diff --git a/src/uu/timeout/Cargo.toml b/src/uu/timeout/Cargo.toml index 19862fdd0..43ec3a6cb 100644 --- a/src/uu/timeout/Cargo.toml +++ b/src/uu/timeout/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_timeout" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "timeout ~ (uutils) run COMMAND with a DURATION time limit" @@ -15,7 +15,7 @@ edition = "2018" path = "src/timeout.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" nix = "0.23.1" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["process", "signals"] } diff --git a/src/uu/timeout/src/timeout.rs b/src/uu/timeout/src/timeout.rs index 42dd256ef..a67632b6c 100644 --- a/src/uu/timeout/src/timeout.rs +++ b/src/uu/timeout/src/timeout.rs @@ -108,7 +108,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); - let app = uu_app().usage(&usage[..]); + let app = uu_app().override_usage(&usage[..]); let matches = app.get_matches_from(args); @@ -124,47 +124,47 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { ) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new("timeout") .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(options::FOREGROUND) + Arg::new(options::FOREGROUND) .long(options::FOREGROUND) .help("when not running timeout directly from a shell prompt, allow COMMAND to read from the TTY and get TTY signals; in this mode, children of COMMAND will not be timed out") ) .arg( - Arg::with_name(options::KILL_AFTER) - .short("k") + Arg::new(options::KILL_AFTER) + .short('k') .takes_value(true)) .arg( - Arg::with_name(options::PRESERVE_STATUS) + Arg::new(options::PRESERVE_STATUS) .long(options::PRESERVE_STATUS) .help("exit with the same status as COMMAND, even when the command times out") ) .arg( - Arg::with_name(options::SIGNAL) - .short("s") + Arg::new(options::SIGNAL) + .short('s') .long(options::SIGNAL) .help("specify the signal to be sent on timeout; SIGNAL may be a name like 'HUP' or a number; see 'kill -l' for a list of signals") .takes_value(true) ) .arg( - Arg::with_name(options::VERBOSE) - .short("v") + Arg::new(options::VERBOSE) + .short('v') .long(options::VERBOSE) .help("diagnose to stderr any signal sent upon timeout") ) .arg( - Arg::with_name(options::DURATION) + Arg::new(options::DURATION) .index(1) .required(true) ) .arg( - Arg::with_name(options::COMMAND) + Arg::new(options::COMMAND) .index(2) .required(true) - .multiple(true) + .multiple_occurrences(true) ) .setting(AppSettings::TrailingVarArg) } diff --git a/src/uu/touch/Cargo.toml b/src/uu/touch/Cargo.toml index faca2cbee..87bbea5f5 100644 --- a/src/uu/touch/Cargo.toml +++ b/src/uu/touch/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_touch" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "touch ~ (uutils) change FILE timestamps" @@ -16,7 +16,7 @@ path = "src/touch.rs" [dependencies] filetime = "0.2.1" -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } time = "0.1.40" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["libc"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/touch/src/touch.rs b/src/uu/touch/src/touch.rs index 6997def09..0ec3a6b1b 100644 --- a/src/uu/touch/src/touch.rs +++ b/src/uu/touch/src/touch.rs @@ -56,7 +56,7 @@ fn usage() -> String { pub fn uumain(args: impl uucore::Args) -> UResult<()> { 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 files = matches.values_of_os(ARG_FILES).unwrap(); @@ -129,43 +129,43 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(options::ACCESS) - .short("a") + Arg::new(options::ACCESS) + .short('a') .help("change only the access time"), ) .arg( - Arg::with_name(options::sources::CURRENT) - .short("t") + Arg::new(options::sources::CURRENT) + .short('t') .help("use [[CC]YY]MMDDhhmm[.ss] instead of the current time") .value_name("STAMP") .takes_value(true), ) .arg( - Arg::with_name(options::sources::DATE) - .short("d") + Arg::new(options::sources::DATE) + .short('d') .long(options::sources::DATE) .help("parse argument and use it instead of current time") .value_name("STRING"), ) .arg( - Arg::with_name(options::MODIFICATION) - .short("m") + Arg::new(options::MODIFICATION) + .short('m') .help("change only the modification time"), ) .arg( - Arg::with_name(options::NO_CREATE) - .short("c") + Arg::new(options::NO_CREATE) + .short('c') .long(options::NO_CREATE) .help("do not create any files"), ) .arg( - Arg::with_name(options::NO_DEREF) - .short("h") + Arg::new(options::NO_DEREF) + .short('h') .long(options::NO_DEREF) .help( "affect each symbolic link instead of any referenced file \ @@ -173,15 +173,16 @@ pub fn uu_app() -> App<'static, 'static> { ), ) .arg( - Arg::with_name(options::sources::REFERENCE) - .short("r") + Arg::new(options::sources::REFERENCE) + .short('r') .long(options::sources::REFERENCE) .alias("ref") // clapv3 .help("use this file's times instead of the current time") - .value_name("FILE"), + .value_name("FILE") + .allow_invalid_utf8(true), ) .arg( - Arg::with_name(options::TIME) + Arg::new(options::TIME) .long(options::TIME) .help( "change only the specified time: \"access\", \"atime\", or \ @@ -193,12 +194,13 @@ pub fn uu_app() -> App<'static, 'static> { .takes_value(true), ) .arg( - Arg::with_name(ARG_FILES) - .multiple(true) + Arg::new(ARG_FILES) + .multiple_occurrences(true) .takes_value(true) - .min_values(1), + .min_values(1) + .allow_invalid_utf8(true), ) - .group(ArgGroup::with_name(options::SOURCES).args(&[ + .group(ArgGroup::new(options::SOURCES).args(&[ options::sources::CURRENT, options::sources::DATE, options::sources::REFERENCE, diff --git a/src/uu/tr/Cargo.toml b/src/uu/tr/Cargo.toml index 6c16a393f..62e4d3e30 100644 --- a/src/uu/tr/Cargo.toml +++ b/src/uu/tr/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_tr" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "tr ~ (uutils) translate characters within input and display" @@ -15,8 +15,8 @@ edition = "2018" path = "src/tr.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } nom = "7.1.0" +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/tr/src/tr.rs b/src/uu/tr/src/tr.rs index cd3627592..9d0396184 100644 --- a/src/uu/tr/src/tr.rs +++ b/src/uu/tr/src/tr.rs @@ -51,7 +51,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let after_help = get_long_usage(); let matches = uu_app() - .usage(&usage[..]) + .override_usage(&usage[..]) .after_help(&after_help[..]) .get_matches_from(args); @@ -144,32 +144,32 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(options::COMPLEMENT) + Arg::new(options::COMPLEMENT) // .visible_short_alias('C') // TODO: requires clap "3.0.0-beta.2" - .short("c") + .short('c') .long(options::COMPLEMENT) .help("use the complement of SET1"), ) .arg( - Arg::with_name("C") // work around for `Arg::visible_short_alias` - .short("C") + Arg::new("C") // work around for `Arg::visible_short_alias` + .short('C') .help("same as -c"), ) .arg( - Arg::with_name(options::DELETE) - .short("d") + Arg::new(options::DELETE) + .short('d') .long(options::DELETE) .help("delete characters in SET1, do not translate"), ) .arg( - Arg::with_name(options::SQUEEZE) + Arg::new(options::SQUEEZE) .long(options::SQUEEZE) - .short("s") + .short('s') .help( "replace each sequence of a repeated character that is \ listed in the last specified SET, with a single occurrence \ @@ -177,14 +177,14 @@ pub fn uu_app() -> App<'static, 'static> { ), ) .arg( - Arg::with_name(options::TRUNCATE_SET1) + Arg::new(options::TRUNCATE_SET1) .long(options::TRUNCATE_SET1) - .short("t") + .short('t') .help("first truncate SET1 to length of SET2"), ) .arg( - Arg::with_name(options::SETS) - .multiple(true) + Arg::new(options::SETS) + .multiple_occurrences(true) .takes_value(true) .min_values(1) .max_values(2), diff --git a/src/uu/true/Cargo.toml b/src/uu/true/Cargo.toml index 12c2b9bca..8237b0ef8 100644 --- a/src/uu/true/Cargo.toml +++ b/src/uu/true/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_true" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "true ~ (uutils) do nothing and succeed" @@ -15,7 +15,7 @@ edition = "2018" path = "src/true.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/true/src/true.rs b/src/uu/true/src/true.rs index b5fbf7c9d..3c1eba32f 100644 --- a/src/uu/true/src/true.rs +++ b/src/uu/true/src/true.rs @@ -14,6 +14,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) } diff --git a/src/uu/truncate/Cargo.toml b/src/uu/truncate/Cargo.toml index 8a8cd3d11..af261beed 100644 --- a/src/uu/truncate/Cargo.toml +++ b/src/uu/truncate/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_truncate" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "truncate ~ (uutils) truncate (or extend) FILE to SIZE" @@ -15,7 +15,7 @@ edition = "2018" path = "src/truncate.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/truncate/src/truncate.rs b/src/uu/truncate/src/truncate.rs index 1729e2a2f..d9ffb31f7 100644 --- a/src/uu/truncate/src/truncate.rs +++ b/src/uu/truncate/src/truncate.rs @@ -97,7 +97,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let long_usage = get_long_usage(); let matches = uu_app() - .usage(&usage[..]) + .override_usage(&usage[..]) .after_help(&long_usage[..]) .get_matches_from(args); @@ -134,41 +134,41 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(options::IO_BLOCKS) - .short("o") + Arg::new(options::IO_BLOCKS) + .short('o') .long(options::IO_BLOCKS) .help("treat SIZE as the number of I/O blocks of the file rather than bytes (NOT IMPLEMENTED)") ) .arg( - Arg::with_name(options::NO_CREATE) - .short("c") + Arg::new(options::NO_CREATE) + .short('c') .long(options::NO_CREATE) .help("do not create files that do not exist") ) .arg( - Arg::with_name(options::REFERENCE) - .short("r") + Arg::new(options::REFERENCE) + .short('r') .long(options::REFERENCE) - .required_unless(options::SIZE) + .required_unless_present(options::SIZE) .help("base the size of each file on the size of RFILE") .value_name("RFILE") ) .arg( - Arg::with_name(options::SIZE) - .short("s") + Arg::new(options::SIZE) + .short('s') .long(options::SIZE) - .required_unless(options::REFERENCE) + .required_unless_present(options::REFERENCE) .help("set or adjust the size of each file according to SIZE, which is in bytes unless --io-blocks is specified") .value_name("SIZE") ) - .arg(Arg::with_name(options::ARG_FILES) + .arg(Arg::new(options::ARG_FILES) .value_name("FILE") - .multiple(true) + .multiple_occurrences(true) .takes_value(true) .required(true) .min_values(1)) diff --git a/src/uu/tsort/Cargo.toml b/src/uu/tsort/Cargo.toml index bdca54bfc..6211ee0af 100644 --- a/src/uu/tsort/Cargo.toml +++ b/src/uu/tsort/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_tsort" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "tsort ~ (uutils) topologically sort input (partially ordered) pairs" @@ -15,7 +15,7 @@ edition = "2018" path = "src/tsort.rs" [dependencies] -clap= "2.33" +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/tsort/src/tsort.rs b/src/uu/tsort/src/tsort.rs index 1b4f5bf49..18348a554 100644 --- a/src/uu/tsort/src/tsort.rs +++ b/src/uu/tsort/src/tsort.rs @@ -93,16 +93,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) - .usage(USAGE) + .override_usage(USAGE) .about(SUMMARY) - .arg( - Arg::with_name(options::FILE) - .default_value("-") - .hidden(true), - ) + .arg(Arg::new(options::FILE).default_value("-").hide(true)) } // We use String as a representation of node here diff --git a/src/uu/tty/Cargo.toml b/src/uu/tty/Cargo.toml index 37b895066..486950831 100644 --- a/src/uu/tty/Cargo.toml +++ b/src/uu/tty/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_tty" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "tty ~ (uutils) display the name of the terminal connected to standard input" @@ -15,7 +15,7 @@ edition = "2018" path = "src/tty.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" atty = "0.2" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } diff --git a/src/uu/tty/src/tty.rs b/src/uu/tty/src/tty.rs index 3a02803c0..498ea1655 100644 --- a/src/uu/tty/src/tty.rs +++ b/src/uu/tty/src/tty.rs @@ -33,8 +33,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { .accept_any(); let matches = uu_app() - .usage(&usage[..]) - .get_matches_from_safe(args) + .override_usage(&usage[..]) + .try_get_matches_from(args) .map_err(|e| UUsageError::new(2, format!("{}", e)))?; let silent = matches.is_present(options::SILENT); @@ -71,15 +71,15 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(options::SILENT) + Arg::new(options::SILENT) .long(options::SILENT) .visible_alias("quiet") - .short("s") + .short('s') .help("print nothing, only return an exit status") .required(false), ) diff --git a/src/uu/uname/Cargo.toml b/src/uu/uname/Cargo.toml index ed5b544f6..e1249ee60 100644 --- a/src/uu/uname/Cargo.toml +++ b/src/uu/uname/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_uname" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "uname ~ (uutils) display system information" @@ -15,7 +15,7 @@ edition = "2018" path = "src/uname.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } platform-info = "0.2" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/uname/src/uname.rs b/src/uu/uname/src/uname.rs index a4801dfc1..29fed29c3 100644 --- a/src/uu/uname/src/uname.rs +++ b/src/uu/uname/src/uname.rs @@ -50,7 +50,7 @@ const HOST_OS: &str = "Redox"; #[uucore_procs::gen_uumain] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = format!("{} [OPTION]...", uucore::execution_phrase()); - let matches = uu_app().usage(&usage[..]).get_matches_from(args); + let matches = uu_app().override_usage(&usage[..]).get_matches_from(args); let uname = PlatformInfo::new().map_err_context(|| "failed to create PlatformInfo".to_string())?; @@ -118,46 +118,46 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) - .arg(Arg::with_name(options::ALL) - .short("a") + .arg(Arg::new(options::ALL) + .short('a') .long(options::ALL) .help("Behave as though all of the options -mnrsv were specified.")) - .arg(Arg::with_name(options::KERNELNAME) - .short("s") + .arg(Arg::new(options::KERNELNAME) + .short('s') .long(options::KERNELNAME) .alias("sysname") // Obsolescent option in GNU uname .help("print the kernel name.")) - .arg(Arg::with_name(options::NODENAME) - .short("n") + .arg(Arg::new(options::NODENAME) + .short('n') .long(options::NODENAME) .help("print the nodename (the nodename may be a name that the system is known by to a communications network).")) - .arg(Arg::with_name(options::KERNELRELEASE) - .short("r") + .arg(Arg::new(options::KERNELRELEASE) + .short('r') .long(options::KERNELRELEASE) .alias("release") // Obsolescent option in GNU uname .help("print the operating system release.")) - .arg(Arg::with_name(options::KERNELVERSION) - .short("v") + .arg(Arg::new(options::KERNELVERSION) + .short('v') .long(options::KERNELVERSION) .help("print the operating system version.")) - .arg(Arg::with_name(options::HWPLATFORM) - .short("i") + .arg(Arg::new(options::HWPLATFORM) + .short('i') .long(options::HWPLATFORM) .help("print the hardware platform (non-portable)")) - .arg(Arg::with_name(options::MACHINE) - .short("m") + .arg(Arg::new(options::MACHINE) + .short('m') .long(options::MACHINE) .help("print the machine hardware name.")) - .arg(Arg::with_name(options::PROCESSOR) - .short("p") + .arg(Arg::new(options::PROCESSOR) + .short('p') .long(options::PROCESSOR) .help("print the processor type (non-portable)")) - .arg(Arg::with_name(options::OS) - .short("o") + .arg(Arg::new(options::OS) + .short('o') .long(options::OS) .help("print the operating system name.")) } diff --git a/src/uu/unexpand/Cargo.toml b/src/uu/unexpand/Cargo.toml index 24e386dd2..37503d216 100644 --- a/src/uu/unexpand/Cargo.toml +++ b/src/uu/unexpand/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_unexpand" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "unexpand ~ (uutils) convert input spaces to tabs" @@ -15,7 +15,7 @@ edition = "2018" path = "src/unexpand.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } unicode-width = "0.1.5" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/unexpand/src/unexpand.rs b/src/uu/unexpand/src/unexpand.rs index 1b227e4ce..83220a012 100644 --- a/src/uu/unexpand/src/unexpand.rs +++ b/src/uu/unexpand/src/unexpand.rs @@ -102,36 +102,36 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { unexpand(Options::new(matches)).map_err_context(String::new) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .name(NAME) .version(crate_version!()) - .usage(USAGE) + .override_usage(USAGE) .about(SUMMARY) - .arg(Arg::with_name(options::FILE).hidden(true).multiple(true)) + .arg(Arg::new(options::FILE).hide(true).multiple_occurrences(true)) .arg( - Arg::with_name(options::ALL) - .short("a") + Arg::new(options::ALL) + .short('a') .long(options::ALL) .help("convert all blanks, instead of just initial blanks") .takes_value(false), ) .arg( - Arg::with_name(options::FIRST_ONLY) + Arg::new(options::FIRST_ONLY) .long(options::FIRST_ONLY) .help("convert only leading sequences of blanks (overrides -a)") .takes_value(false), ) .arg( - Arg::with_name(options::TABS) - .short("t") + Arg::new(options::TABS) + .short('t') .long(options::TABS) .long_help("use comma separated LIST of tab positions or have tabs N characters apart instead of 8 (enables -a)") .takes_value(true) ) .arg( - Arg::with_name(options::NO_UTF8) - .short("U") + Arg::new(options::NO_UTF8) + .short('U') .long(options::NO_UTF8) .takes_value(false) .help("interpret input file as 8-bit ASCII rather than UTF-8")) diff --git a/src/uu/uniq/Cargo.toml b/src/uu/uniq/Cargo.toml index fbefc4c6c..eba1bb3c7 100644 --- a/src/uu/uniq/Cargo.toml +++ b/src/uu/uniq/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_uniq" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "uniq ~ (uutils) filter identical adjacent lines from input" @@ -15,7 +15,7 @@ edition = "2018" path = "src/uniq.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } strum = "0.21" strum_macros = "0.21" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/uniq/src/uniq.rs b/src/uu/uniq/src/uniq.rs index bea64cc53..80675ff1a 100644 --- a/src/uu/uniq/src/uniq.rs +++ b/src/uu/uniq/src/uniq.rs @@ -261,7 +261,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let long_usage = get_long_usage(); let matches = uu_app() - .usage(&usage[..]) + .override_usage(&usage[..]) .after_help(&long_usage[..]) .get_matches_from(args); @@ -299,16 +299,18 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { ) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(options::ALL_REPEATED) - .short("D") + Arg::new(options::ALL_REPEATED) + .short('D') .long(options::ALL_REPEATED) .possible_values(&[ - Delimiters::None.as_ref(), Delimiters::Prepend.as_ref(), Delimiters::Separate.as_ref() + "none", + "prepend", + "separate" ]) .help("print all duplicate lines. Delimiting is done with blank lines. [default: none]") .value_name("delimit-method") @@ -316,11 +318,13 @@ pub fn uu_app() -> App<'static, 'static> { .max_values(1), ) .arg( - Arg::with_name(options::GROUP) + Arg::new(options::GROUP) .long(options::GROUP) .possible_values(&[ - Delimiters::Separate.as_ref(), Delimiters::Prepend.as_ref(), - Delimiters::Append.as_ref(), Delimiters::Both.as_ref() + "separate", + "prepend", + "append", + "both", ]) .help("show all items, separating groups with an empty line. [default: separate]") .value_name("group-method") @@ -333,59 +337,59 @@ pub fn uu_app() -> App<'static, 'static> { ]), ) .arg( - Arg::with_name(options::CHECK_CHARS) - .short("w") + Arg::new(options::CHECK_CHARS) + .short('w') .long(options::CHECK_CHARS) .help("compare no more than N characters in lines") .value_name("N"), ) .arg( - Arg::with_name(options::COUNT) - .short("c") + Arg::new(options::COUNT) + .short('c') .long(options::COUNT) .help("prefix lines by the number of occurrences"), ) .arg( - Arg::with_name(options::IGNORE_CASE) - .short("i") + Arg::new(options::IGNORE_CASE) + .short('i') .long(options::IGNORE_CASE) .help("ignore differences in case when comparing"), ) .arg( - Arg::with_name(options::REPEATED) - .short("d") + Arg::new(options::REPEATED) + .short('d') .long(options::REPEATED) .help("only print duplicate lines"), ) .arg( - Arg::with_name(options::SKIP_CHARS) - .short("s") + Arg::new(options::SKIP_CHARS) + .short('s') .long(options::SKIP_CHARS) .help("avoid comparing the first N characters") .value_name("N"), ) .arg( - Arg::with_name(options::SKIP_FIELDS) - .short("f") + Arg::new(options::SKIP_FIELDS) + .short('f') .long(options::SKIP_FIELDS) .help("avoid comparing the first N fields") .value_name("N"), ) .arg( - Arg::with_name(options::UNIQUE) - .short("u") + Arg::new(options::UNIQUE) + .short('u') .long(options::UNIQUE) .help("only print unique lines"), ) .arg( - Arg::with_name(options::ZERO_TERMINATED) - .short("z") + Arg::new(options::ZERO_TERMINATED) + .short('z') .long(options::ZERO_TERMINATED) .help("end lines with 0 byte, not newline"), ) .arg( - Arg::with_name(ARG_FILES) - .multiple(true) + Arg::new(ARG_FILES) + .multiple_occurrences(true) .takes_value(true) .max_values(2), ) diff --git a/src/uu/unlink/Cargo.toml b/src/uu/unlink/Cargo.toml index 7b4456d87..6d69bac97 100644 --- a/src/uu/unlink/Cargo.toml +++ b/src/uu/unlink/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_unlink" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "unlink ~ (uutils) remove a (file system) link to FILE" @@ -15,7 +15,7 @@ edition = "2018" path = "src/unlink.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/unlink/src/unlink.rs b/src/uu/unlink/src/unlink.rs index 58bb5442c..aa924523f 100644 --- a/src/uu/unlink/src/unlink.rs +++ b/src/uu/unlink/src/unlink.rs @@ -27,9 +27,14 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { remove_file(path).map_err_context(|| format!("cannot unlink {}", path.quote())) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) - .arg(Arg::with_name(OPT_PATH).required(true).hidden(true)) + .arg( + Arg::new(OPT_PATH) + .required(true) + .hide(true) + .allow_invalid_utf8(true), + ) } diff --git a/src/uu/uptime/Cargo.toml b/src/uu/uptime/Cargo.toml index f19f5fe59..81ed71356 100644 --- a/src/uu/uptime/Cargo.toml +++ b/src/uu/uptime/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_uptime" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "uptime ~ (uutils) display dynamic system information" @@ -16,7 +16,7 @@ path = "src/uptime.rs" [dependencies] chrono = "^0.4.11" -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["libc", "utmpx"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/uptime/src/uptime.rs b/src/uu/uptime/src/uptime.rs index eabcd1abf..4b52a68a7 100644 --- a/src/uu/uptime/src/uptime.rs +++ b/src/uu/uptime/src/uptime.rs @@ -39,7 +39,7 @@ fn usage() -> String { #[uucore_procs::gen_uumain] pub fn uumain(args: impl uucore::Args) -> UResult<()> { 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 (boot_time, user_count) = process_utmpx(); let uptime = get_uptime(boot_time); @@ -62,13 +62,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(options::SINCE) - .short("s") + Arg::new(options::SINCE) + .short('s') .long(options::SINCE) .help("system up since"), ) diff --git a/src/uu/users/Cargo.toml b/src/uu/users/Cargo.toml index d8ee738f0..f92214ff3 100644 --- a/src/uu/users/Cargo.toml +++ b/src/uu/users/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_users" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "users ~ (uutils) display names of currently logged-in users" @@ -15,7 +15,7 @@ edition = "2018" path = "src/users.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["utmpx"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/users/src/users.rs b/src/uu/users/src/users.rs index d0768d8d1..4d7cd9c7f 100644 --- a/src/uu/users/src/users.rs +++ b/src/uu/users/src/users.rs @@ -36,7 +36,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let after_help = get_long_usage(); let matches = uu_app() - .usage(&usage[..]) + .override_usage(&usage[..]) .after_help(&after_help[..]) .get_matches_from(args); @@ -64,9 +64,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) - .arg(Arg::with_name(ARG_FILES).takes_value(true).max_values(1)) + .arg(Arg::new(ARG_FILES).takes_value(true).max_values(1)) } diff --git a/src/uu/wc/Cargo.toml b/src/uu/wc/Cargo.toml index 547114b04..4617f0d55 100644 --- a/src/uu/wc/Cargo.toml +++ b/src/uu/wc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_wc" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "wc ~ (uutils) display newline, word, and byte counts for input" @@ -15,7 +15,7 @@ edition = "2018" path = "src/wc.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["pipes"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } bytecount = "0.6.2" diff --git a/src/uu/wc/src/wc.rs b/src/uu/wc/src/wc.rs index 0d061caba..4f092b814 100644 --- a/src/uu/wc/src/wc.rs +++ b/src/uu/wc/src/wc.rs @@ -137,7 +137,7 @@ impl Input { pub fn uumain(args: impl uucore::Args) -> UResult<()> { 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 mut inputs: Vec = matches .values_of_os(ARG_FILES) @@ -162,41 +162,46 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { wc(inputs, &settings) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(options::BYTES) - .short("c") + Arg::new(options::BYTES) + .short('c') .long(options::BYTES) .help("print the byte counts"), ) .arg( - Arg::with_name(options::CHAR) - .short("m") + Arg::new(options::CHAR) + .short('m') .long(options::CHAR) .help("print the character counts"), ) .arg( - Arg::with_name(options::LINES) - .short("l") + Arg::new(options::LINES) + .short('l') .long(options::LINES) .help("print the newline counts"), ) .arg( - Arg::with_name(options::MAX_LINE_LENGTH) - .short("L") + Arg::new(options::MAX_LINE_LENGTH) + .short('L') .long(options::MAX_LINE_LENGTH) .help("print the length of the longest line"), ) .arg( - Arg::with_name(options::WORDS) - .short("w") + Arg::new(options::WORDS) + .short('w') .long(options::WORDS) .help("print the word counts"), ) - .arg(Arg::with_name(ARG_FILES).multiple(true).takes_value(true)) + .arg( + Arg::new(ARG_FILES) + .multiple_occurrences(true) + .takes_value(true) + .allow_invalid_utf8(true), + ) } fn word_count_from_reader( diff --git a/src/uu/who/Cargo.toml b/src/uu/who/Cargo.toml index b1a32c4c6..437705064 100644 --- a/src/uu/who/Cargo.toml +++ b/src/uu/who/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_who" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "who ~ (uutils) display information about currently logged-in users" @@ -15,9 +15,9 @@ edition = "2018" path = "src/who.rs" [dependencies] +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["utmpx"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } -clap = { version = "2.33", features = ["wrap_help"] } [[bin]] name = "who" diff --git a/src/uu/who/src/who.rs b/src/uu/who/src/who.rs index 14f39536d..0428be048 100644 --- a/src/uu/who/src/who.rs +++ b/src/uu/who/src/who.rs @@ -69,7 +69,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let after_help = get_long_usage(); let matches = uu_app() - .usage(&usage[..]) + .override_usage(&usage[..]) .after_help(&after_help[..]) .get_matches_from(args); @@ -161,101 +161,101 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { who.exec() } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(options::ALL) + Arg::new(options::ALL) .long(options::ALL) - .short("a") + .short('a') .help("same as -b -d --login -p -r -t -T -u"), ) .arg( - Arg::with_name(options::BOOT) + Arg::new(options::BOOT) .long(options::BOOT) - .short("b") + .short('b') .help("time of last system boot"), ) .arg( - Arg::with_name(options::DEAD) + Arg::new(options::DEAD) .long(options::DEAD) - .short("d") + .short('d') .help("print dead processes"), ) .arg( - Arg::with_name(options::HEADING) + Arg::new(options::HEADING) .long(options::HEADING) - .short("H") + .short('H') .help("print line of column headings"), ) .arg( - Arg::with_name(options::LOGIN) + Arg::new(options::LOGIN) .long(options::LOGIN) - .short("l") + .short('l') .help("print system login processes"), ) .arg( - Arg::with_name(options::LOOKUP) + Arg::new(options::LOOKUP) .long(options::LOOKUP) .help("attempt to canonicalize hostnames via DNS"), ) .arg( - Arg::with_name(options::ONLY_HOSTNAME_USER) - .short("m") + Arg::new(options::ONLY_HOSTNAME_USER) + .short('m') .help("only hostname and user associated with stdin"), ) .arg( - Arg::with_name(options::PROCESS) + Arg::new(options::PROCESS) .long(options::PROCESS) - .short("p") + .short('p') .help("print active processes spawned by init"), ) .arg( - Arg::with_name(options::COUNT) + Arg::new(options::COUNT) .long(options::COUNT) - .short("q") + .short('q') .help("all login names and number of users logged on"), ) .arg( - Arg::with_name(options::RUNLEVEL) + Arg::new(options::RUNLEVEL) .long(options::RUNLEVEL) - .short("r") + .short('r') .help(RUNLEVEL_HELP), ) .arg( - Arg::with_name(options::SHORT) + Arg::new(options::SHORT) .long(options::SHORT) - .short("s") + .short('s') .help("print only name, line, and time (default)"), ) .arg( - Arg::with_name(options::TIME) + Arg::new(options::TIME) .long(options::TIME) - .short("t") + .short('t') .help("print last system clock change"), ) .arg( - Arg::with_name(options::USERS) + Arg::new(options::USERS) .long(options::USERS) - .short("u") + .short('u') .help("list users logged in"), ) .arg( - Arg::with_name(options::MESG) + Arg::new(options::MESG) .long(options::MESG) - .short("T") + .short('T') // .visible_short_alias('w') // TODO: requires clap "3.0.0-beta.2" .visible_aliases(&["message", "writable"]) .help("add user's message status as +, - or ?"), ) .arg( - Arg::with_name("w") // work around for `Arg::visible_short_alias` - .short("w") + Arg::new("w") // work around for `Arg::visible_short_alias` + .short('w') .help("same as -T"), ) .arg( - Arg::with_name(options::FILE) + Arg::new(options::FILE) .takes_value(true) .min_values(1) .max_values(2), diff --git a/src/uu/whoami/Cargo.toml b/src/uu/whoami/Cargo.toml index a01bbc2b3..7c3436425 100644 --- a/src/uu/whoami/Cargo.toml +++ b/src/uu/whoami/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_whoami" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "whoami ~ (uutils) display user name of current effective user ID" @@ -15,7 +15,7 @@ edition = "2018" path = "src/whoami.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/whoami/src/whoami.rs b/src/uu/whoami/src/whoami.rs index 0820588ee..f3986cf45 100644 --- a/src/uu/whoami/src/whoami.rs +++ b/src/uu/whoami/src/whoami.rs @@ -27,7 +27,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) diff --git a/src/uu/yes/Cargo.toml b/src/uu/yes/Cargo.toml index 5e698e847..b8d121cdf 100644 --- a/src/uu/yes/Cargo.toml +++ b/src/uu/yes/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_yes" -version = "0.0.9" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "yes ~ (uutils) repeatedly display a line with STRING (or 'y')" @@ -15,7 +15,7 @@ edition = "2018" path = "src/yes.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["pipes"] } uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/yes/src/yes.rs b/src/uu/yes/src/yes.rs index bbedc0af1..51701214a 100644 --- a/src/uu/yes/src/yes.rs +++ b/src/uu/yes/src/yes.rs @@ -46,8 +46,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app() -> App<'static, 'static> { - app_from_crate!().arg(Arg::with_name("STRING").index(1).multiple(true)) +pub fn uu_app<'a>() -> App<'a> { + app_from_crate!().arg(Arg::new("STRING").index(1).multiple_occurrences(true)) } fn prepare_buffer<'a>(input: &'a str, buffer: &'a mut [u8; BUF_SIZE]) -> &'a [u8] { diff --git a/src/uucore/Cargo.toml b/src/uucore/Cargo.toml index ff064e5fc..4cb92b30d 100644 --- a/src/uucore/Cargo.toml +++ b/src/uucore/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uucore" -version = "0.0.11" +version = "0.0.12" authors = ["uutils developers"] license = "MIT" description = "uutils ~ 'core' uutils code library (cross-platform)" @@ -16,7 +16,7 @@ edition = "2018" path="src/lib/lib.rs" [dependencies] -clap = "2.33.3" +clap = "3.0" dns-lookup = { version="1.0.5", optional=true } dunce = "1.0.0" wild = "2.0" @@ -36,7 +36,7 @@ walkdir = { version="2.3.2", optional=true } nix = { version="0.23.1", optional=true } [dev-dependencies] -clap = "2.33.3" +clap = "3.0" lazy_static = "1.3" [target.'cfg(target_os = "windows")'.dependencies] diff --git a/src/uucore/src/lib/features/perms.rs b/src/uucore/src/lib/features/perms.rs index 16ee01b88..128334f1c 100644 --- a/src/uucore/src/lib/features/perms.rs +++ b/src/uucore/src/lib/features/perms.rs @@ -410,7 +410,7 @@ pub mod options { pub const ARG_FILES: &str = "FILE"; } -type GidUidFilterParser<'a> = fn(&ArgMatches<'a>) -> UResult<(Option, Option, IfFrom)>; +type GidUidFilterParser = fn(&ArgMatches) -> UResult<(Option, Option, IfFrom)>; /// Base implementation for `chgrp` and `chown`. /// @@ -420,10 +420,10 @@ type GidUidFilterParser<'a> = fn(&ArgMatches<'a>) -> UResult<(Option, Optio /// from `ArgMatches`. /// `groups_only` determines whether verbose output will only mention the group. pub fn chown_base<'a>( - mut app: App<'a, 'a>, + mut app: App<'a>, args: impl crate::Args, add_arg_if_not_reference: &'a str, - parse_gid_uid_and_filter: GidUidFilterParser<'a>, + parse_gid_uid_and_filter: GidUidFilterParser, groups_only: bool, ) -> UResult<()> { let args: Vec<_> = args.collect(); @@ -445,17 +445,17 @@ pub fn chown_base<'a>( // add both positional arguments // arg_group is only required if app = app.arg( - Arg::with_name(add_arg_if_not_reference) + Arg::new(add_arg_if_not_reference) .value_name(add_arg_if_not_reference) .required(true) .takes_value(true) - .multiple(false), + .multiple_occurrences(false), ) } app = app.arg( - Arg::with_name(options::ARG_FILES) + Arg::new(options::ARG_FILES) .value_name(options::ARG_FILES) - .multiple(true) + .multiple_occurrences(true) .takes_value(true) .required(true) .min_values(1), diff --git a/src/uucore/src/lib/mods/backup_control.rs b/src/uucore/src/lib/mods/backup_control.rs index 167c51386..2d1e4c4d5 100644 --- a/src/uucore/src/lib/mods/backup_control.rs +++ b/src/uucore/src/lib/mods/backup_control.rs @@ -47,7 +47,7 @@ //! .arg(backup_control::arguments::backup()) //! .arg(backup_control::arguments::backup_no_args()) //! .arg(backup_control::arguments::suffix()) -//! .usage(&usage[..]) +//! .override_usage(&usage[..]) //! .after_help(&*format!( //! "{}\n{}", //! long_usage, @@ -206,8 +206,8 @@ pub mod arguments { pub static OPT_SUFFIX: &str = "backupopt_suffix"; /// '--backup' argument - pub fn backup() -> clap::Arg<'static, 'static> { - clap::Arg::with_name(OPT_BACKUP) + pub fn backup<'a>() -> clap::Arg<'a> { + clap::Arg::new(OPT_BACKUP) .long("backup") .help("make a backup of each existing destination file") .takes_value(true) @@ -217,16 +217,16 @@ pub mod arguments { } /// '-b' argument - pub fn backup_no_args() -> clap::Arg<'static, 'static> { - clap::Arg::with_name(OPT_BACKUP_NO_ARG) - .short("b") + pub fn backup_no_args<'a>() -> clap::Arg<'a> { + clap::Arg::new(OPT_BACKUP_NO_ARG) + .short('b') .help("like --backup but does not accept an argument") } /// '-S, --suffix' argument - pub fn suffix() -> clap::Arg<'static, 'static> { - clap::Arg::with_name(OPT_SUFFIX) - .short("S") + pub fn suffix<'a>() -> clap::Arg<'a> { + clap::Arg::new(OPT_SUFFIX) + .short('S') .long("suffix") .help("override the usual backup suffix") .takes_value(true) @@ -462,7 +462,7 @@ mod tests { // Environment variable for "VERSION_CONTROL" static ENV_VERSION_CONTROL: &str = "VERSION_CONTROL"; - fn make_app() -> clap::App<'static, 'static> { + fn make_app() -> clap::App<'static> { App::new("app") .arg(arguments::backup()) .arg(arguments::backup_no_args()) diff --git a/src/uucore_procs/Cargo.toml b/src/uucore_procs/Cargo.toml index 9505a8ba4..040198063 100644 --- a/src/uucore_procs/Cargo.toml +++ b/src/uucore_procs/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uucore_procs" -version = "0.0.8" +version = "0.0.12" authors = ["Roy Ivy III "] license = "MIT" description = "uutils ~ 'uucore' proc-macros" diff --git a/tests/by-util/test_install.rs b/tests/by-util/test_install.rs index 339a40454..97169f934 100644 --- a/tests/by-util/test_install.rs +++ b/tests/by-util/test_install.rs @@ -9,16 +9,6 @@ use std::process::Command; #[cfg(target_os = "linux")] use std::thread::sleep; -#[test] -fn test_install_help() { - let (_, mut ucmd) = at_and_ucmd!(); - - ucmd.arg("--help") - .succeeds() - .no_stderr() - .stdout_contains("FLAGS:"); -} - #[test] fn test_install_basic() { let (at, mut ucmd) = at_and_ucmd!(); diff --git a/tests/by-util/test_link.rs b/tests/by-util/test_link.rs index 3219a6591..5a84364e9 100644 --- a/tests/by-util/test_link.rs +++ b/tests/by-util/test_link.rs @@ -58,6 +58,6 @@ fn test_link_three_arguments() { "test_link_argument3", ]; ucmd.args(&arguments[..]).fails().stderr_contains( - format!("error: The value '{}' was provided to '...', but it wasn't expecting any more values", arguments[2]), + format!("error: The value '{}' was provided to '...' but it wasn't expecting any more values", arguments[2]), ); } diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index b5d49337d..f39b4d914 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -1995,48 +1995,42 @@ fn test_ls_ignore_hide() { scene .ucmd() - .arg("--hide") - .arg("*") + .arg("--hide=*") .arg("-1") .succeeds() .stdout_only(""); scene .ucmd() - .arg("--ignore") - .arg("*") + .arg("--ignore=*") .arg("-1") .succeeds() .stdout_only(""); scene .ucmd() - .arg("--ignore") - .arg("irrelevant pattern") + .arg("--ignore=irrelevant pattern") .arg("-1") .succeeds() .stdout_only("CONTRIBUTING.md\nREADME.md\nREADMECAREFULLY.md\nsome_other_file\n"); scene .ucmd() - .arg("--ignore") - .arg("README*.md") + .arg("--ignore=README*.md") .arg("-1") .succeeds() .stdout_only("CONTRIBUTING.md\nsome_other_file\n"); scene .ucmd() - .arg("--hide") - .arg("README*.md") + .arg("--hide=README*.md") .arg("-1") .succeeds() .stdout_only("CONTRIBUTING.md\nsome_other_file\n"); scene .ucmd() - .arg("--ignore") - .arg("*.md") + .arg("--ignore=*.md") .arg("-1") .succeeds() .stdout_only("some_other_file\n"); @@ -2044,8 +2038,7 @@ fn test_ls_ignore_hide() { scene .ucmd() .arg("-a") - .arg("--ignore") - .arg("*.md") + .arg("--ignore=*.md") .arg("-1") .succeeds() .stdout_only(".\n..\nsome_other_file\n"); @@ -2053,8 +2046,7 @@ fn test_ls_ignore_hide() { scene .ucmd() .arg("-a") - .arg("--hide") - .arg("*.md") + .arg("--hide=*.md") .arg("-1") .succeeds() .stdout_only(".\n..\nCONTRIBUTING.md\nREADME.md\nREADMECAREFULLY.md\nsome_other_file\n"); @@ -2062,8 +2054,7 @@ fn test_ls_ignore_hide() { scene .ucmd() .arg("-A") - .arg("--ignore") - .arg("*.md") + .arg("--ignore=*.md") .arg("-1") .succeeds() .stdout_only("some_other_file\n"); @@ -2071,8 +2062,7 @@ fn test_ls_ignore_hide() { scene .ucmd() .arg("-A") - .arg("--hide") - .arg("*.md") + .arg("--hide=*.md") .arg("-1") .succeeds() .stdout_only("CONTRIBUTING.md\nREADME.md\nREADMECAREFULLY.md\nsome_other_file\n"); @@ -2080,30 +2070,24 @@ fn test_ls_ignore_hide() { // Stacking multiple patterns scene .ucmd() - .arg("--ignore") - .arg("README*") - .arg("--ignore") - .arg("CONTRIBUTING*") + .arg("--ignore=README*") + .arg("--ignore=CONTRIBUTING*") .arg("-1") .succeeds() .stdout_only("some_other_file\n"); scene .ucmd() - .arg("--hide") - .arg("README*") - .arg("--ignore") - .arg("CONTRIBUTING*") + .arg("--hide=README*") + .arg("--ignore=CONTRIBUTING*") .arg("-1") .succeeds() .stdout_only("some_other_file\n"); scene .ucmd() - .arg("--hide") - .arg("README*") - .arg("--hide") - .arg("CONTRIBUTING*") + .arg("--hide=README*") + .arg("--hide=CONTRIBUTING*") .arg("-1") .succeeds() .stdout_only("some_other_file\n"); @@ -2111,8 +2095,7 @@ fn test_ls_ignore_hide() { // Invalid patterns scene .ucmd() - .arg("--ignore") - .arg("READ[ME") + .arg("--ignore=READ[ME") .arg("-1") .succeeds() .stderr_contains(&"Invalid pattern") @@ -2120,8 +2103,7 @@ fn test_ls_ignore_hide() { scene .ucmd() - .arg("--hide") - .arg("READ[ME") + .arg("--hide=READ[ME") .arg("-1") .succeeds() .stderr_contains(&"Invalid pattern") diff --git a/tests/by-util/test_mknod.rs b/tests/by-util/test_mknod.rs index 1d39372ac..f42ab0b90 100644 --- a/tests/by-util/test_mknod.rs +++ b/tests/by-util/test_mknod.rs @@ -86,7 +86,6 @@ fn test_mknod_character_device_requires_major_and_minor() { .arg("1") .arg("c") .fails() - .status_code(1) .stderr_contains(&"Invalid value for ''"); new_ucmd!() .arg("test_file") @@ -94,7 +93,6 @@ fn test_mknod_character_device_requires_major_and_minor() { .arg("c") .arg("1") .fails() - .status_code(1) .stderr_contains(&"Invalid value for ''"); } @@ -104,7 +102,6 @@ fn test_mknod_invalid_arg() { new_ucmd!() .arg("--foo") .fails() - .status_code(1) .no_stdout() .stderr_contains(&"Found argument '--foo' which wasn't expected"); } diff --git a/tests/by-util/test_pinky.rs b/tests/by-util/test_pinky.rs index 17cec1b4b..05525e927 100644 --- a/tests/by-util/test_pinky.rs +++ b/tests/by-util/test_pinky.rs @@ -58,7 +58,7 @@ fn test_long_format_multiple_users() { #[test] fn test_long_format_wo_user() { // "no username specified; at least one must be specified when using -l" - new_ucmd!().arg("-l").fails().code_is(1); + new_ucmd!().arg("-l").fails(); } #[cfg(unix)] diff --git a/tests/by-util/test_rm.rs b/tests/by-util/test_rm.rs index f846e064b..f813f071c 100644 --- a/tests/by-util/test_rm.rs +++ b/tests/by-util/test_rm.rs @@ -315,18 +315,6 @@ fn test_rm_verbose_slash() { assert!(!at.file_exists(file_a)); } -#[test] -fn test_rm_silently_accepts_presume_input_tty1() { - let (at, mut ucmd) = at_and_ucmd!(); - let file_1 = "test_rm_silently_accepts_presume_input_tty1"; - - at.touch(file_1); - - ucmd.arg("--presume-input-tty").arg(file_1).succeeds(); - - assert!(!at.file_exists(file_1)); -} - #[test] fn test_rm_silently_accepts_presume_input_tty2() { let (at, mut ucmd) = at_and_ucmd!(); @@ -338,15 +326,3 @@ fn test_rm_silently_accepts_presume_input_tty2() { assert!(!at.file_exists(file_2)); } - -#[test] -fn test_rm_silently_accepts_presume_input_tty3() { - let (at, mut ucmd) = at_and_ucmd!(); - let file_3 = "test_rm_silently_accepts_presume_input_tty3"; - - at.touch(file_3); - - ucmd.arg("----presume-input-tty").arg(file_3).succeeds(); - - assert!(!at.file_exists(file_3)); -} diff --git a/tests/by-util/test_shuf.rs b/tests/by-util/test_shuf.rs index cbc01f8cd..901b6f8be 100644 --- a/tests/by-util/test_shuf.rs +++ b/tests/by-util/test_shuf.rs @@ -154,9 +154,7 @@ fn test_shuf_echo_and_input_range_not_allowed() { new_ucmd!() .args(&["-e", "0", "-i", "0-2"]) .fails() - .stderr_contains( - "The argument '--input-range ' cannot be used with '--echo ...'", - ); + .stderr_contains("cannot be used with"); } #[test] @@ -164,7 +162,7 @@ fn test_shuf_input_range_and_file_not_allowed() { new_ucmd!() .args(&["-i", "0-9", "file"]) .fails() - .stderr_contains("The argument '' cannot be used with '--input-range '"); + .stderr_contains("cannot be used with"); } #[test] diff --git a/tests/by-util/test_sort.rs b/tests/by-util/test_sort.rs index 76095ff76..d472d4b5e 100644 --- a/tests/by-util/test_sort.rs +++ b/tests/by-util/test_sort.rs @@ -996,7 +996,8 @@ fn test_conflict_check_out() { .arg("-o=/dev/null") .fails() .stderr_contains( - "error: The argument '--output ' cannot be used with '--check", + // the rest of the message might be subject to change + "error: The argument", ); } } diff --git a/tests/by-util/test_stdbuf.rs b/tests/by-util/test_stdbuf.rs index 3b03a1d4c..e38183c25 100644 --- a/tests/by-util/test_stdbuf.rs +++ b/tests/by-util/test_stdbuf.rs @@ -29,9 +29,9 @@ fn test_stdbuf_no_buffer_option_fails() { ts.ucmd().args(&["head"]).fails().stderr_is(&format!( "error: The following required arguments were not provided:\n \ - --error \n \ --input \n \ - --output \n\n\ + --output \n \ + --error \n\n\ USAGE:\n \ {1} {0} OPTION... COMMAND\n\n\ For more information try --help", diff --git a/tests/by-util/test_tail.rs b/tests/by-util/test_tail.rs index a020f6235..e863e34b7 100644 --- a/tests/by-util/test_tail.rs +++ b/tests/by-util/test_tail.rs @@ -3,7 +3,7 @@ // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. -// spell-checker:ignore (ToDO) abcdefghijklmnopqrstuvwxyz efghijklmnopqrstuvwxyz vwxyz emptyfile +// spell-checker:ignore (ToDO) abcdefghijklmnopqrstuvwxyz efghijklmnopqrstuvwxyz vwxyz emptyfile bogusfile extern crate tail; @@ -475,3 +475,17 @@ fn test_tail_bytes_for_funny_files() { .code_is(exp_result.code()); } } + +#[test] +fn test_no_such_file() { + new_ucmd!() + .arg("bogusfile") + .fails() + .no_stdout() + .stderr_contains("cannot open 'bogusfile' for reading: No such file or directory"); +} + +#[test] +fn test_no_trailing_newline() { + new_ucmd!().pipe_in("x").succeeds().stdout_only("x"); +} diff --git a/tests/by-util/test_tr.rs b/tests/by-util/test_tr.rs index 5e8a5f846..ba41a8044 100644 --- a/tests/by-util/test_tr.rs +++ b/tests/by-util/test_tr.rs @@ -287,13 +287,8 @@ fn test_interpret_backslash_at_eol_literally() { } #[test] -// FixME: panicked at 'failed to write to stdin of child: Broken pipe (os error 32) -#[cfg(not(target_os = "freebsd"))] fn test_more_than_2_sets() { - new_ucmd!() - .args(&["'abcdef'", "'a'", "'b'"]) - .pipe_in("hello world") - .fails(); + new_ucmd!().args(&["'abcdef'", "'a'", "'b'"]).fails(); } #[test] diff --git a/tests/by-util/test_who.rs b/tests/by-util/test_who.rs index d05715517..d91026903 100644 --- a/tests/by-util/test_who.rs +++ b/tests/by-util/test_who.rs @@ -136,7 +136,7 @@ fn test_arg1_arg2() { #[test] fn test_too_many_args() { const EXPECTED: &str = - "error: The value 'u' was provided to '...', but it wasn't expecting any more values"; + "error: The value 'u' was provided to '...' but it wasn't expecting any more values"; let args = ["am", "i", "u"]; new_ucmd!().args(&args).fails().stderr_contains(EXPECTED);