From feefe235f77c92e96da35592248d18d914951ff7 Mon Sep 17 00:00:00 2001 From: Justin ! Date: Tue, 20 Aug 2024 22:56:58 -0400 Subject: [PATCH] WIP: upgrade clap to 4.5 --- Cargo.lock | 231 +++++++++--------- Cargo.nix | 612 ++++++++++++++++++++++------------------------- Cargo.toml | 18 +- src/cli.rs | 214 +++++++++-------- src/lib.rs | 2 - src/main.rs | 4 +- src/ops.rs | 2 +- src/ops/error.rs | 6 +- 8 files changed, 508 insertions(+), 581 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 219c98b..57c4e20 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,12 +27,52 @@ dependencies = [ ] [[package]] -name = "ansi_term" -version = "0.12.1" +name = "anstream" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" dependencies = [ - "winapi", + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" + +[[package]] +name = "anstyle-parse" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", ] [[package]] @@ -52,17 +92,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", -] - [[package]] name = "autocfg" version = "1.2.0" @@ -137,18 +166,50 @@ checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" [[package]] name = "clap" -version = "2.34.0" +version = "4.5.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +checksum = "ed6719fffa43d0d87e5fd8caeab59be1554fb028cd30edc88fc4369b17971019" dependencies = [ - "ansi_term", - "atty", - "bitflags 1.2.1", + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", "strsim", - "textwrap", - "unicode-width", ] +[[package]] +name = "clap_derive" +version = "4.5.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" + +[[package]] +name = "colorchoice" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" + [[package]] name = "crossbeam-channel" version = "0.5.12" @@ -315,21 +376,9 @@ checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "heck" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" -dependencies = [ - "unicode-segmentation", -] - -[[package]] -name = "hermit-abi" -version = "0.1.19" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" @@ -384,11 +433,17 @@ version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" dependencies = [ - "hermit-abi 0.3.9", + "hermit-abi", "libc", "windows-sys 0.52.0", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[package]] name = "itoa" version = "1.0.11" @@ -466,6 +521,7 @@ dependencies = [ "anyhow", "atomicwrites", "bincode", + "clap", "crossbeam-channel", "ctrlc", "directories", @@ -483,7 +539,6 @@ dependencies = [ "serde_json", "slog", "slog-term", - "structopt", "tempfile", "thiserror", "vec1", @@ -676,15 +731,6 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro2" -version = "0.4.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -dependencies = [ - "unicode-xid", -] - [[package]] name = "proc-macro2" version = "1.0.79" @@ -717,22 +763,13 @@ version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" -[[package]] -name = "quote" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" -dependencies = [ - "proc-macro2 0.4.30", -] - [[package]] name = "quote" version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ - "proc-macro2 1.0.79", + "proc-macro2", ] [[package]] @@ -956,9 +993,9 @@ version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ - "proc-macro2 1.0.79", - "quote 1.0.35", - "syn 2.0.58", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -999,42 +1036,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - -[[package]] -name = "structopt" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16c2cdbf9cc375f15d1b4141bc48aeef444806655cd0e904207edc8d68d86ed7" -dependencies = [ - "clap", - "structopt-derive", -] - -[[package]] -name = "structopt-derive" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53010261a84b37689f9ed7d395165029f9cc7abb9f56bbfe86bee2597ed25107" -dependencies = [ - "heck", - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", -] - -[[package]] -name = "syn" -version = "0.15.44" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "unicode-xid", -] +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" @@ -1042,8 +1046,8 @@ version = "2.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" dependencies = [ - "proc-macro2 1.0.79", - "quote 1.0.35", + "proc-macro2", + "quote", "unicode-ident", ] @@ -1080,15 +1084,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - [[package]] name = "thiserror" version = "1.0.58" @@ -1104,9 +1099,9 @@ version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ - "proc-macro2 1.0.79", - "quote 1.0.35", - "syn 2.0.58", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -1166,22 +1161,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] -name = "unicode-segmentation" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" - -[[package]] -name = "unicode-width" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" - -[[package]] -name = "unicode-xid" -version = "0.1.0" +name = "utf8parse" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" diff --git a/Cargo.nix b/Cargo.nix index 34680f3..b7d3a1f 100644 --- a/Cargo.nix +++ b/Cargo.nix @@ -152,28 +152,116 @@ rec { }; resolvedDefaultFeatures = [ "perf-literal" "std" ]; }; - "ansi_term" = rec { - crateName = "ansi_term"; - version = "0.12.1"; - edition = "2015"; - sha256 = "1ljmkbilxgmhavxvxqa7qvm6f3fjggi7q2l3a72q9x0cxjvrnanm"; - authors = [ - "ogham@bsago.me" - "Ryan Scheel (Havvy) " - "Josh Triplett " + "anstream" = rec { + crateName = "anstream"; + version = "0.6.15"; + edition = "2021"; + sha256 = "09nm4qj34kiwgzczdvj14x7hgsb235g4sqsay3xsz7zqn4d5rqb4"; + dependencies = [ + { + name = "anstyle"; + packageId = "anstyle"; + } + { + name = "anstyle-parse"; + packageId = "anstyle-parse"; + } + { + name = "anstyle-query"; + packageId = "anstyle-query"; + optional = true; + } + { + name = "anstyle-wincon"; + packageId = "anstyle-wincon"; + optional = true; + target = { target, features }: (target."windows" or false); + } + { + name = "colorchoice"; + packageId = "colorchoice"; + } + { + name = "is_terminal_polyfill"; + packageId = "is_terminal_polyfill"; + } + { + name = "utf8parse"; + packageId = "utf8parse"; + } ]; + features = { + "auto" = [ "dep:anstyle-query" ]; + "default" = [ "auto" "wincon" ]; + "wincon" = [ "dep:anstyle-wincon" ]; + }; + resolvedDefaultFeatures = [ "auto" "default" "wincon" ]; + }; + "anstyle" = rec { + crateName = "anstyle"; + version = "1.0.8"; + edition = "2021"; + sha256 = "1cfmkza63xpn1kkz844mgjwm9miaiz4jkyczmwxzivcsypk1vv0v"; + features = { + "default" = [ "std" ]; + }; + resolvedDefaultFeatures = [ "default" "std" ]; + }; + "anstyle-parse" = rec { + crateName = "anstyle-parse"; + version = "0.2.5"; + edition = "2021"; + sha256 = "1jy12rvgbldflnb2x7mcww9dcffw1mx22nyv6p3n7d62h0gdwizb"; + libName = "anstyle_parse"; dependencies = [ { - name = "winapi"; - packageId = "winapi"; - target = { target, features }: ("windows" == target."os"); - features = [ "consoleapi" "errhandlingapi" "fileapi" "handleapi" "processenv" ]; + name = "utf8parse"; + packageId = "utf8parse"; + optional = true; } ]; features = { - "derive_serde_style" = [ "serde" ]; - "serde" = [ "dep:serde" ]; + "core" = [ "dep:arrayvec" ]; + "default" = [ "utf8" ]; + "utf8" = [ "dep:utf8parse" ]; }; + resolvedDefaultFeatures = [ "default" "utf8" ]; + }; + "anstyle-query" = rec { + crateName = "anstyle-query"; + version = "1.1.1"; + edition = "2021"; + sha256 = "0aj22iy4pzk6mz745sfrm1ym14r0y892jhcrbs8nkj7nqx9gqdkd"; + libName = "anstyle_query"; + dependencies = [ + { + name = "windows-sys"; + packageId = "windows-sys 0.52.0"; + target = { target, features }: (target."windows" or false); + features = [ "Win32_System_Console" "Win32_Foundation" ]; + } + ]; + + }; + "anstyle-wincon" = rec { + crateName = "anstyle-wincon"; + version = "3.0.4"; + edition = "2021"; + sha256 = "1y2pkvsrdxbcwircahb4wimans2pzmwwxad7ikdhj5lpdqdlxxsv"; + libName = "anstyle_wincon"; + dependencies = [ + { + name = "anstyle"; + packageId = "anstyle"; + } + { + name = "windows-sys"; + packageId = "windows-sys 0.52.0"; + target = { target, features }: (target."windows" or false); + features = [ "Win32_System_Console" "Win32_Foundation" ]; + } + ]; + }; "anyhow" = rec { crateName = "anyhow"; @@ -215,35 +303,6 @@ rec { } ]; - }; - "atty" = rec { - crateName = "atty"; - version = "0.2.14"; - edition = "2015"; - sha256 = "1s7yslcs6a28c5vz7jwj63lkfgyx8mx99fdirlhi9lbhhzhrpcyr"; - authors = [ - "softprops " - ]; - dependencies = [ - { - name = "hermit-abi"; - packageId = "hermit-abi 0.1.19"; - target = { target, features }: ("hermit" == target."os"); - } - { - name = "libc"; - packageId = "libc"; - usesDefaultFeatures = false; - target = { target, features }: (target."unix" or false); - } - { - name = "winapi"; - packageId = "winapi"; - target = { target, features }: (target."windows" or false); - features = [ "consoleapi" "processenv" "minwinbase" "minwindef" "winbase" ]; - } - ]; - }; "autocfg" = rec { crateName = "autocfg"; @@ -398,6 +457,7 @@ rec { version = "0.1.10"; edition = "2018"; sha256 = "08h80ihs74jcyp24cd75wwabygbbdgl05k6p5dmq8akbr78vv1a7"; + libName = "cfg_if"; authors = [ "Alex Crichton " ]; @@ -412,6 +472,7 @@ rec { version = "1.0.0"; edition = "2018"; sha256 = "1za0vb97n4brpzpv8lsbnzmq5r8f2b0cpqqr0sy8h5bn751xxwds"; + libName = "cfg_if"; authors = [ "Alex Crichton " ]; @@ -433,64 +494,135 @@ rec { }; "clap" = rec { crateName = "clap"; - version = "2.34.0"; - edition = "2018"; - sha256 = "071q5d8jfwbazi6zhik9xwpacx5i6kb2vkzy060vhf0c3120aqd0"; - authors = [ - "Kevin K. " - ]; + version = "4.5.16"; + edition = "2021"; + crateBin = []; + sha256 = "068hjwbrndn4iz4fsc6d52q4ymg1kfsymjnqbxzdil23zbzijrzd"; dependencies = [ { - name = "ansi_term"; - packageId = "ansi_term"; + name = "clap_builder"; + packageId = "clap_builder"; + usesDefaultFeatures = false; + } + { + name = "clap_derive"; + packageId = "clap_derive"; optional = true; - target = { target, features }: (!(target."windows" or false)); } + ]; + features = { + "cargo" = [ "clap_builder/cargo" ]; + "color" = [ "clap_builder/color" ]; + "debug" = [ "clap_builder/debug" "clap_derive?/debug" ]; + "default" = [ "std" "color" "help" "usage" "error-context" "suggestions" ]; + "deprecated" = [ "clap_builder/deprecated" "clap_derive?/deprecated" ]; + "derive" = [ "dep:clap_derive" ]; + "env" = [ "clap_builder/env" ]; + "error-context" = [ "clap_builder/error-context" ]; + "help" = [ "clap_builder/help" ]; + "std" = [ "clap_builder/std" ]; + "string" = [ "clap_builder/string" ]; + "suggestions" = [ "clap_builder/suggestions" ]; + "unicode" = [ "clap_builder/unicode" ]; + "unstable-doc" = [ "clap_builder/unstable-doc" "derive" ]; + "unstable-ext" = [ "clap_builder/unstable-ext" ]; + "unstable-styles" = [ "clap_builder/unstable-styles" ]; + "unstable-v5" = [ "clap_builder/unstable-v5" "clap_derive?/unstable-v5" "deprecated" ]; + "usage" = [ "clap_builder/usage" ]; + "wrap_help" = [ "clap_builder/wrap_help" ]; + }; + resolvedDefaultFeatures = [ "color" "default" "derive" "error-context" "help" "std" "suggestions" "usage" ]; + }; + "clap_builder" = rec { + crateName = "clap_builder"; + version = "4.5.15"; + edition = "2021"; + sha256 = "1dmas5z20yqmlmfhykr38pn1hkcnr4jzxjw4cs2f6lkn2wmyqsi1"; + dependencies = [ { - name = "atty"; - packageId = "atty"; + name = "anstream"; + packageId = "anstream"; optional = true; } { - name = "bitflags"; - packageId = "bitflags 1.2.1"; + name = "anstyle"; + packageId = "anstyle"; + } + { + name = "clap_lex"; + packageId = "clap_lex"; } { name = "strsim"; packageId = "strsim"; optional = true; } + ]; + features = { + "color" = [ "dep:anstream" ]; + "debug" = [ "dep:backtrace" ]; + "default" = [ "std" "color" "help" "usage" "error-context" "suggestions" ]; + "std" = [ "anstyle/std" ]; + "suggestions" = [ "dep:strsim" "error-context" ]; + "unicode" = [ "dep:unicode-width" "dep:unicase" ]; + "unstable-doc" = [ "cargo" "wrap_help" "env" "unicode" "string" "unstable-ext" ]; + "unstable-styles" = [ "color" ]; + "unstable-v5" = [ "deprecated" ]; + "wrap_help" = [ "help" "dep:terminal_size" ]; + }; + resolvedDefaultFeatures = [ "color" "error-context" "help" "std" "suggestions" "usage" ]; + }; + "clap_derive" = rec { + crateName = "clap_derive"; + version = "4.5.13"; + edition = "2021"; + sha256 = "1860xq3rbgwsqwcj9rd14cky9iiywwx86j7fvvngdjixbyfka7ah"; + procMacro = true; + dependencies = [ + { + name = "heck"; + packageId = "heck"; + } { - name = "textwrap"; - packageId = "textwrap"; + name = "proc-macro2"; + packageId = "proc-macro2"; + } + { + name = "quote"; + packageId = "quote"; } { - name = "unicode-width"; - packageId = "unicode-width"; + name = "syn"; + packageId = "syn"; + features = [ "full" ]; } ]; features = { - "ansi_term" = [ "dep:ansi_term" ]; - "atty" = [ "dep:atty" ]; - "clippy" = [ "dep:clippy" ]; - "color" = [ "ansi_term" "atty" ]; - "default" = [ "suggestions" "color" "vec_map" ]; - "doc" = [ "yaml" ]; - "strsim" = [ "dep:strsim" ]; - "suggestions" = [ "strsim" ]; - "term_size" = [ "dep:term_size" ]; - "vec_map" = [ "dep:vec_map" ]; - "wrap_help" = [ "term_size" "textwrap/term_size" ]; - "yaml" = [ "yaml-rust" ]; - "yaml-rust" = [ "dep:yaml-rust" ]; + "raw-deprecated" = [ "deprecated" ]; + "unstable-v5" = [ "deprecated" ]; }; - resolvedDefaultFeatures = [ "ansi_term" "atty" "color" "no_cargo" "strsim" "suggestions" ]; + resolvedDefaultFeatures = [ "default" ]; + }; + "clap_lex" = rec { + crateName = "clap_lex"; + version = "0.7.2"; + edition = "2021"; + sha256 = "15zcrc2fa6ycdzaihxghf48180bnvzsivhf0fmah24bnnaf76qhl"; + + }; + "colorchoice" = rec { + crateName = "colorchoice"; + version = "1.0.2"; + edition = "2021"; + sha256 = "1h18ph538y8yjmbpaf8li98l0ifms2xmh3rax9666c5qfjfi3zfk"; + }; "crossbeam-channel" = rec { crateName = "crossbeam-channel"; version = "0.5.12"; edition = "2021"; sha256 = "159gp30clv2ci3r473659ii04pjznspb3g9gwkhj2lavkhmb0gdb"; + libName = "crossbeam_channel"; dependencies = [ { name = "crossbeam-utils"; @@ -509,6 +641,7 @@ rec { version = "0.8.19"; edition = "2021"; sha256 = "0iakrb1b8fjqrag7wphl94d10irhbh2fw1g444xslsywqyn3p3i4"; + libName = "crossbeam_utils"; features = { "default" = [ "std" ]; "loom" = [ "dep:loom" ]; @@ -598,6 +731,7 @@ rec { version = "2.0.0"; edition = "2018"; sha256 = "1q9kr151h9681wwp6is18750ssghz6j9j7qm7qi1ngcwy7mzi35r"; + libName = "dirs_next"; authors = [ "The @xdg-rs members" ]; @@ -618,6 +752,7 @@ rec { version = "0.3.7"; edition = "2015"; sha256 = "19md1cnkazham8a6kh22v12d8hh3raqahfk6yb043vrjr68is78v"; + libName = "dirs_sys"; authors = [ "Simon Ochsenreither " ]; @@ -647,6 +782,7 @@ rec { version = "0.1.2"; edition = "2018"; sha256 = "0kavhavdxv4phzj4l0psvh55hszwnr0rcz8sxbvx20pyqi2a3gaf"; + libName = "dirs_sys_next"; authors = [ "The @xdg-rs members" ]; @@ -758,6 +894,7 @@ rec { edition = "2021"; crateBin = []; sha256 = "1jdg9xq830hghzrqkbnx8nda58a7z6mh8b6vlg5mj87v4l2ji135"; + libName = "file_id"; authors = [ "Daniel Faust " ]; @@ -810,6 +947,7 @@ rec { version = "4.1.0"; edition = "2018"; sha256 = "1liz67v8b0gcs8r31vxkvm2jzgl9p14i78yfqx81c8sdv817mvkn"; + libName = "fsevent_sys"; authors = [ "Pierre Baillet " ]; @@ -826,6 +964,7 @@ rec { version = "0.1.1"; edition = "2018"; sha256 = "1fnkqrbz7ixxzsb04bsz9p0zzazanma8znfdqjvh39n14vapfvx0"; + libName = "fuchsia_cprng"; authors = [ "Erick Tryzelaar " ]; @@ -924,47 +1063,17 @@ rec { }; "heck" = rec { crateName = "heck"; - version = "0.3.3"; - edition = "2018"; - sha256 = "0b0kkr790p66lvzn9nsmfjvydrbmh9z5gb664jchwgw64vxiwqkd"; - authors = [ - "Without Boats " - ]; - dependencies = [ - { - name = "unicode-segmentation"; - packageId = "unicode-segmentation"; - } - ]; + version = "0.5.0"; + edition = "2021"; + sha256 = "1sjmpsdl8czyh9ywl3qcsfsq9a307dg4ni2vnlwgnzzqhc4y0113"; }; - "hermit-abi 0.1.19" = rec { - crateName = "hermit-abi"; - version = "0.1.19"; - edition = "2018"; - sha256 = "0cxcm8093nf5fyn114w8vxbrbcyvv91d4015rdnlgfll7cs6gd32"; - authors = [ - "Stefan Lankes" - ]; - dependencies = [ - { - name = "libc"; - packageId = "libc"; - usesDefaultFeatures = false; - } - ]; - features = { - "compiler_builtins" = [ "dep:compiler_builtins" ]; - "core" = [ "dep:core" ]; - "rustc-dep-of-std" = [ "core" "compiler_builtins/rustc-dep-of-std" "libc/rustc-dep-of-std" ]; - }; - resolvedDefaultFeatures = [ "default" ]; - }; - "hermit-abi 0.3.9" = rec { + "hermit-abi" = rec { crateName = "hermit-abi"; version = "0.3.9"; edition = "2021"; sha256 = "092hxjbjnq5fmz66grd9plxd0sh6ssg5fhgwwwqbrzgzkjwdycfj"; + libName = "hermit_abi"; authors = [ "Stefan Lankes" ]; @@ -985,6 +1094,7 @@ rec { src = if ((lib.versionOlder builtins.nixVersion "2.4pre20211007") || (lib.versionOlder "2.5" builtins.nixVersion )) then lib.cleanSourceWith { filter = sourceFilter; src = ./vendor/human-panic; } else ./vendor/human-panic; + libName = "human_panic"; authors = [ "Yoshua Wuyts " "Pascal Hertleif " @@ -1058,6 +1168,7 @@ rec { version = "0.1.5"; edition = "2015"; sha256 = "1syhjgvkram88my04kv03s0zwa66mdwa5v7ddja3pzwvx2sh4p70"; + libName = "inotify_sys"; authors = [ "Hanno Braun " ]; @@ -1096,6 +1207,7 @@ rec { version = "0.4.12"; edition = "2018"; sha256 = "12vk6g0f94zlxl6mdh5gc4jdjb469n9k9s7y3vb0iml05gpzagzj"; + libName = "is_terminal"; authors = [ "softprops " "Dan Gohman " @@ -1103,7 +1215,7 @@ rec { dependencies = [ { name = "hermit-abi"; - packageId = "hermit-abi 0.3.9"; + packageId = "hermit-abi"; target = { target, features }: ("hermit" == target."os"); } { @@ -1127,6 +1239,15 @@ rec { ]; }; + "is_terminal_polyfill" = rec { + crateName = "is_terminal_polyfill"; + version = "1.70.1"; + edition = "2021"; + sha256 = "1kwfgglh91z33kl0w5i338mfpa3zs0hidq5j4ny4rmjwrikchhvr"; + features = { + }; + resolvedDefaultFeatures = [ "default" ]; + }; "itoa" = rec { crateName = "itoa"; version = "1.0.11"; @@ -1164,6 +1285,7 @@ rec { version = "1.0.4"; edition = "2018"; sha256 = "12w3wi90y4kwis4k9g6fp0kqjdmc6l00j16g8mgbhac7vbzjb5pd"; + libName = "kqueue_sys"; authors = [ "William Orr " "Daniel (dmilith) Dettlaff " @@ -1240,6 +1362,7 @@ rec { version = "0.4.13"; edition = "2021"; sha256 = "172k2c6422gsc914ig8rh99mb9yc7siw6ikc3d9xw1k7vx0s3k81"; + libName = "linux_raw_sys"; authors = [ "Dan Gohman " ]; @@ -1334,6 +1457,11 @@ rec { name = "bincode"; packageId = "bincode"; } + { + name = "clap"; + packageId = "clap"; + features = [ "derive" "error-context" ]; + } { name = "crossbeam-channel"; packageId = "crossbeam-channel"; @@ -1400,12 +1528,6 @@ rec { name = "slog-term"; packageId = "slog-term"; } - { - name = "structopt"; - packageId = "structopt"; - usesDefaultFeatures = false; - features = [ "suggestions" "color" "no_cargo" ]; - } { name = "tempfile"; packageId = "tempfile"; @@ -1824,6 +1946,7 @@ rec { version = "0.1.0"; edition = "2021"; sha256 = "1ndiyg82q73783jq18isi71a7mjh56wxrk52rlvyx0mi5z9ibmai"; + libName = "num_conv"; authors = [ "Jacob Pratt " ]; @@ -1834,6 +1957,7 @@ rec { version = "0.2.18"; edition = "2018"; sha256 = "0yjib8p2p9kzmaz48xwhs69w5dh1wipph9jgnillzd2x33jz03fs"; + libName = "num_traits"; authors = [ "The Rust Project Developers" ]; @@ -2002,6 +2126,7 @@ rec { version = "0.2.17"; edition = "2018"; sha256 = "1pp6g52aw970adv3x2310n7glqnji96z0a9wiamzw89ibf0ayh2v"; + libName = "ppv_lite86"; authors = [ "The CryptoCorrosion Contributors" ]; @@ -2010,30 +2135,12 @@ rec { }; resolvedDefaultFeatures = [ "simd" "std" ]; }; - "proc-macro2 0.4.30" = rec { - crateName = "proc-macro2"; - version = "0.4.30"; - edition = "2015"; - sha256 = "0nd71fl24sys066jrha6j7i34nfkjv44yzw8yww9742wmc8j0gfg"; - authors = [ - "Alex Crichton " - ]; - dependencies = [ - { - name = "unicode-xid"; - packageId = "unicode-xid"; - } - ]; - features = { - "default" = [ "proc-macro" ]; - }; - resolvedDefaultFeatures = [ "default" "proc-macro" ]; - }; - "proc-macro2 1.0.79" = rec { + "proc-macro2" = rec { crateName = "proc-macro2"; version = "1.0.79"; edition = "2021"; sha256 = "0bn004ybzdqid81cqppr5c9jrvqsxv50x60sxc41cwpmk0igydg8"; + libName = "proc_macro2"; authors = [ "David Tolnay " "Alex Crichton " @@ -2125,34 +2232,14 @@ rec { version = "1.2.3"; edition = "2015"; sha256 = "1q6za3v78hsspisc197bg3g7rpc989qycy8ypr8ap8igv10ikl51"; + libName = "quick_error"; authors = [ "Paul Colomiets " "Colin Kiegel " ]; }; - "quote 0.6.13" = rec { - crateName = "quote"; - version = "0.6.13"; - edition = "2015"; - sha256 = "1qgqq48jymp5h4y082aanf25hrw6bpb678xh3zw993qfhxmkpqkc"; - authors = [ - "David Tolnay " - ]; - dependencies = [ - { - name = "proc-macro2"; - packageId = "proc-macro2 0.4.30"; - usesDefaultFeatures = false; - } - ]; - features = { - "default" = [ "proc-macro" ]; - "proc-macro" = [ "proc-macro2/proc-macro" ]; - }; - resolvedDefaultFeatures = [ "default" "proc-macro" ]; - }; - "quote 1.0.35" = rec { + "quote" = rec { crateName = "quote"; version = "1.0.35"; edition = "2018"; @@ -2163,7 +2250,7 @@ rec { dependencies = [ { name = "proc-macro2"; - packageId = "proc-macro2 1.0.79"; + packageId = "proc-macro2"; usesDefaultFeatures = false; } ]; @@ -2564,6 +2651,7 @@ rec { version = "0.4.6"; edition = "2021"; sha256 = "1spaq7y4im7s56d1gxa2hi4hzf6dwswb1bv8xyavzya7k25kpf46"; + libName = "regex_automata"; authors = [ "The Rust Project Developers" "Andrew Gallant " @@ -2624,6 +2712,7 @@ rec { version = "0.6.29"; edition = "2018"; sha256 = "1qgj49vm6y3zn1hi09x91jvgkl2b1fiaq402skj83280ggfwcqpi"; + libName = "regex_syntax"; authors = [ "The Rust Project Developers" ]; @@ -2638,6 +2727,7 @@ rec { version = "0.8.3"; edition = "2021"; sha256 = "0mhzkm1pkqg6y53xv056qciazlg47pq0czqs94cn302ckvi49bdd"; + libName = "regex_syntax"; authors = [ "The Rust Project Developers" "Andrew Gallant " @@ -2672,6 +2762,7 @@ rec { version = "0.1.23"; edition = "2015"; sha256 = "0xnbk2bmyzshacjm2g1kd4zzv2y2az14bw3sjccq5qkpmsfvn9nn"; + libName = "rustc_demangle"; authors = [ "Alex Crichton " ]; @@ -2819,6 +2910,7 @@ rec { version = "1.0.6"; edition = "2018"; sha256 = "00h5j1w87dmhnvbv9l8bic3y7xxsnjmssvifw2ayvgx9mb1ivz4k"; + libName = "same_file"; authors = [ "Andrew Gallant " ]; @@ -2890,19 +2982,19 @@ rec { dependencies = [ { name = "proc-macro2"; - packageId = "proc-macro2 1.0.79"; + packageId = "proc-macro2"; usesDefaultFeatures = false; features = [ "proc-macro" ]; } { name = "quote"; - packageId = "quote 1.0.35"; + packageId = "quote"; usesDefaultFeatures = false; features = [ "proc-macro" ]; } { name = "syn"; - packageId = "syn 2.0.58"; + packageId = "syn"; usesDefaultFeatures = false; features = [ "clone-impls" "derive" "parsing" "printing" "proc-macro" ]; } @@ -2971,6 +3063,7 @@ rec { version = "2.9.1"; edition = "2018"; sha256 = "1s0h8qhqnvy5a7m7gmnca2a2d5m5a4sz1hc26xfgxawqp7825q5n"; + libName = "slog_term"; authors = [ "Dawid Ciężarkiewicz " ]; @@ -3022,114 +3115,16 @@ rec { }; "strsim" = rec { crateName = "strsim"; - version = "0.8.0"; + version = "0.11.1"; edition = "2015"; - sha256 = "0sjsm7hrvjdifz661pjxq5w4hf190hx53fra8dfvamacvff139cf"; + sha256 = "0kzvqlw8hxqb7y598w1s0hxlnmi84sg5vsipp3yg5na5d1rvba3x"; authors = [ - "Danny Guo " + "Danny Guo " + "maxbachmann " ]; }; - "structopt" = rec { - crateName = "structopt"; - version = "0.2.18"; - edition = "2015"; - sha256 = "1mvfv1l8vp3y402fkl2wcl34hi7gmr4bqha13dfz2xf3kjzwvhhn"; - authors = [ - "Guillaume Pinot " - "others" - ]; - dependencies = [ - { - name = "clap"; - packageId = "clap"; - usesDefaultFeatures = false; - } - { - name = "structopt-derive"; - packageId = "structopt-derive"; - } - ]; - features = { - "color" = [ "clap/color" ]; - "debug" = [ "clap/debug" ]; - "default" = [ "clap/default" ]; - "doc" = [ "clap/doc" ]; - "lints" = [ "clap/lints" ]; - "nightly" = [ "structopt-derive/nightly" ]; - "no_cargo" = [ "clap/no_cargo" ]; - "paw" = [ "structopt-derive/paw" ]; - "suggestions" = [ "clap/suggestions" ]; - "wrap_help" = [ "clap/wrap_help" ]; - "yaml" = [ "clap/yaml" ]; - }; - resolvedDefaultFeatures = [ "color" "no_cargo" "suggestions" ]; - }; - "structopt-derive" = rec { - crateName = "structopt-derive"; - version = "0.2.18"; - edition = "2015"; - sha256 = "01sis9z5kqmyhvzbnmlzpdxcry99a0b9blypksgnhdsbm1hh40ak"; - procMacro = true; - authors = [ - "Guillaume Pinot " - ]; - dependencies = [ - { - name = "heck"; - packageId = "heck"; - } - { - name = "proc-macro2"; - packageId = "proc-macro2 0.4.30"; - } - { - name = "quote"; - packageId = "quote 0.6.13"; - } - { - name = "syn"; - packageId = "syn 0.15.44"; - } - ]; - features = { - "nightly" = [ "proc-macro2/nightly" ]; - }; - }; - "syn 0.15.44" = rec { - crateName = "syn"; - version = "0.15.44"; - edition = "2015"; - sha256 = "1id5g6x6zihv3j7hwrw3m1jp636bg8dpi671r7zy3jvpkavb794w"; - authors = [ - "David Tolnay " - ]; - dependencies = [ - { - name = "proc-macro2"; - packageId = "proc-macro2 0.4.30"; - usesDefaultFeatures = false; - } - { - name = "quote"; - packageId = "quote 0.6.13"; - optional = true; - usesDefaultFeatures = false; - } - { - name = "unicode-xid"; - packageId = "unicode-xid"; - } - ]; - features = { - "default" = [ "derive" "parsing" "printing" "clone-impls" "proc-macro" ]; - "printing" = [ "quote" ]; - "proc-macro" = [ "proc-macro2/proc-macro" "quote/proc-macro" ]; - "quote" = [ "dep:quote" ]; - }; - resolvedDefaultFeatures = [ "clone-impls" "default" "derive" "parsing" "printing" "proc-macro" "quote" ]; - }; - "syn 2.0.58" = rec { + "syn" = rec { crateName = "syn"; version = "2.0.58"; edition = "2021"; @@ -3140,12 +3135,12 @@ rec { dependencies = [ { name = "proc-macro2"; - packageId = "proc-macro2 1.0.79"; + packageId = "proc-macro2"; usesDefaultFeatures = false; } { name = "quote"; - packageId = "quote 1.0.35"; + packageId = "quote"; optional = true; usesDefaultFeatures = false; } @@ -3160,7 +3155,7 @@ rec { "proc-macro" = [ "proc-macro2/proc-macro" "quote?/proc-macro" ]; "test" = [ "syn-test-suite/all-features" ]; }; - resolvedDefaultFeatures = [ "clone-impls" "default" "derive" "parsing" "printing" "proc-macro" ]; + resolvedDefaultFeatures = [ "clone-impls" "default" "derive" "full" "parsing" "printing" "proc-macro" ]; }; "tempdir" = rec { crateName = "tempdir"; @@ -3248,25 +3243,6 @@ rec { }; resolvedDefaultFeatures = [ "default" ]; }; - "textwrap" = rec { - crateName = "textwrap"; - version = "0.11.0"; - edition = "2015"; - sha256 = "0q5hky03ik3y50s9sz25r438bc4nwhqc6dqwynv4wylc807n29nk"; - authors = [ - "Martin Geisler " - ]; - dependencies = [ - { - name = "unicode-width"; - packageId = "unicode-width"; - } - ]; - features = { - "hyphenation" = [ "dep:hyphenation" ]; - "term_size" = [ "dep:term_size" ]; - }; - }; "thiserror" = rec { crateName = "thiserror"; version = "1.0.58"; @@ -3289,21 +3265,22 @@ rec { edition = "2021"; sha256 = "1xylyqcb8rv5yh2yf97hg4n4kg27qccc0ijafr1zqklrhahkn7y6"; procMacro = true; + libName = "thiserror_impl"; authors = [ "David Tolnay " ]; dependencies = [ { name = "proc-macro2"; - packageId = "proc-macro2 1.0.79"; + packageId = "proc-macro2"; } { name = "quote"; - packageId = "quote 1.0.35"; + packageId = "quote"; } { name = "syn"; - packageId = "syn 2.0.58"; + packageId = "syn"; } ]; @@ -3414,6 +3391,7 @@ rec { version = "0.1.2"; edition = "2021"; sha256 = "1wx3qizcihw6z151hywfzzyd1y5dl804ydyxci6qm07vbakpr4pg"; + libName = "time_core"; authors = [ "Jacob Pratt " "Time contributors" @@ -3426,6 +3404,7 @@ rec { edition = "2021"; sha256 = "1kqwxvfh2jkpg38fy673d6danh1bhcmmbsmffww3mphgail2l99z"; procMacro = true; + libName = "time_macros"; authors = [ "Jacob Pratt " "Time contributors" @@ -3469,48 +3448,20 @@ rec { version = "1.0.12"; edition = "2018"; sha256 = "0jzf1znfpb2gx8nr8mvmyqs1crnv79l57nxnbiszc7xf7ynbjm1k"; + libName = "unicode_ident"; authors = [ "David Tolnay " ]; }; - "unicode-segmentation" = rec { - crateName = "unicode-segmentation"; - version = "1.11.0"; + "utf8parse" = rec { + crateName = "utf8parse"; + version = "0.2.2"; edition = "2018"; - sha256 = "00kjpwp1g8fqm45drmwivlacn3y9jx73bvs09n6s3x73nqi7vj6l"; - authors = [ - "kwantam " - "Manish Goregaokar " - ]; - features = { - }; - }; - "unicode-width" = rec { - crateName = "unicode-width"; - version = "0.1.11"; - edition = "2015"; - sha256 = "11ds4ydhg8g7l06rlmh712q41qsrd0j0h00n1jm74kww3kqk65z5"; - authors = [ - "kwantam " - "Manish Goregaokar " - ]; - features = { - "compiler_builtins" = [ "dep:compiler_builtins" ]; - "core" = [ "dep:core" ]; - "rustc-dep-of-std" = [ "std" "core" "compiler_builtins" ]; - "std" = [ "dep:std" ]; - }; - resolvedDefaultFeatures = [ "default" ]; - }; - "unicode-xid" = rec { - crateName = "unicode-xid"; - version = "0.1.0"; - edition = "2015"; - sha256 = "1z57lqh4s18rr4x0j4fw4fmp9hf9346h0kmdgqsqx0fhjr3k0wpw"; + sha256 = "088807qwjq46azicqwbhlmzwrbkz7l4hpw43sdkdyyk524vdxaq6"; authors = [ - "erick.tryzelaar " - "kwantam " + "Joe Wilm " + "Christian Duerr " ]; features = { }; @@ -3654,13 +3605,14 @@ rec { features = { "debug" = [ "impl-debug" ]; }; - resolvedDefaultFeatures = [ "consoleapi" "errhandlingapi" "fileapi" "handleapi" "knownfolders" "minwinbase" "minwindef" "ntsecapi" "objbase" "processenv" "profileapi" "shlobj" "std" "sysinfoapi" "winbase" "wincon" "winerror" "winnt" ]; + resolvedDefaultFeatures = [ "consoleapi" "errhandlingapi" "fileapi" "handleapi" "knownfolders" "minwindef" "ntsecapi" "objbase" "processenv" "profileapi" "shlobj" "std" "sysinfoapi" "winbase" "wincon" "winerror" "winnt" ]; }; "winapi-i686-pc-windows-gnu" = rec { crateName = "winapi-i686-pc-windows-gnu"; version = "0.4.0"; edition = "2015"; sha256 = "1dmpa6mvcvzz16zg6d5vrfy4bxgg541wxrcip7cnshi06v38ffxc"; + libName = "winapi_i686_pc_windows_gnu"; authors = [ "Peter Atashian " ]; @@ -3671,6 +3623,7 @@ rec { version = "0.1.6"; edition = "2021"; sha256 = "15i5lm39wd44004i9d5qspry2cynkrpvwzghr6s2c3dsk28nz7pj"; + libName = "winapi_util"; authors = [ "Andrew Gallant " ]; @@ -3689,6 +3642,7 @@ rec { version = "0.4.0"; edition = "2015"; sha256 = "0gqq64czqb64kskjryj8isp62m2sgvx25yyj3kpc2myh85w24bki"; + libName = "winapi_x86_64_pc_windows_gnu"; authors = [ "Peter Atashian " ]; @@ -3699,6 +3653,7 @@ rec { version = "0.48.0"; edition = "2018"; sha256 = "1aan23v5gs7gya1lc46hqn9mdh8yph3fhxmhxlw36pn6pqc28zb7"; + libName = "windows_sys"; authors = [ "Microsoft" ]; @@ -3992,6 +3947,7 @@ rec { version = "0.52.0"; edition = "2021"; sha256 = "0gd3v4ji88490zgb6b5mq5zgbvwv7zx1ibn8v3x83rwcdbryaar8"; + libName = "windows_sys"; authors = [ "Microsoft" ]; @@ -4239,6 +4195,7 @@ rec { version = "0.48.5"; edition = "2018"; sha256 = "034ljxqshifs1lan89xwpcy1hp0lhdh4b5n0d2z4fwjx2piacbws"; + libName = "windows_targets"; authors = [ "Microsoft" ]; @@ -4286,6 +4243,7 @@ rec { version = "0.52.4"; edition = "2021"; sha256 = "06sdd7fin3dj9cmlg6n1dw0n1l10jhn9b8ckz1cqf0drb9z7plvx"; + libName = "windows_targets"; authors = [ "Microsoft" ]; diff --git a/Cargo.toml b/Cargo.toml index 8eb11b3..af70ce3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,23 +22,6 @@ tempfile = "3.1.0" anyhow = "1.0" thiserror = "1.0" -# TODO: update to 0.3 -structopt.version = "0.2" - -# TODO: update to 0.3 -structopt.default-features = false - -# TODO: update to 0.3 -structopt.features = [ - # "default", - "suggestions", - "color", - # "wrap_help", - # "yaml", - # "debug", - "no_cargo", - # "doc" (enables yaml) -] # logging; slog = { version = "2.7.0", features = [ "release_max_level_debug", @@ -58,6 +41,7 @@ md5 = "0.7.0" vec1 = ">= 1.1.0, <1.7.0" human-panic = { path = "vendor/human-panic" } notify-debouncer-full = "0.3.1" +clap = { version = "4.5.16", features = ["derive", "error-context"] } [dev-dependencies] # 1.0.0 requires at least rust 1.50 diff --git a/src/cli.rs b/src/cli.rs index eca0678..83ca590 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -8,24 +8,26 @@ // // See MAINTAINERS.md for details on internal and non-internal commands. -use std::{convert::TryFrom, path::PathBuf, time::Duration}; - -use structopt::clap; +use std::{convert::TryFrom, path::PathBuf, str::FromStr, time::Duration}; use crate::{project::ProjectFile, AbsDirPathBuf, AbsPathBuf, Installable}; +use clap::{ + error::{ContextKind, ContextValue}, + Parser, Subcommand, +}; -#[derive(StructOpt, Debug)] -#[structopt(name = "lorri")] +#[derive(Parser, Debug)] +#[command(name = "lorri", version)] /// Global arguments which set global program state. Most /// arguments will be to sub-commands. pub struct Arguments { /// Activate debug logging. Multiple occurrences are accepted for backwards compatibility, but /// have no effect. This will display all messages lorri logs. - #[structopt(short = "v", long = "verbose", parse(from_occurrences))] + #[arg(short, long, default_value_t = 0, required = false)] pub verbosity: u8, /// Sub-command to execute - #[structopt(subcommand)] + #[command(subcommand)] pub command: Command, } @@ -38,69 +40,56 @@ pub enum Verbosity { Debug, } -#[derive(StructOpt, Debug)] +#[derive(Subcommand, Debug)] /// Sub-commands which lorri can execute pub enum Command { /// Emit shell script intended to be evaluated as part of direnv's .envrc, via: `eval "$(lorri /// direnv)"` - #[structopt(name = "direnv")] Direnv(DirenvOptions), /// Remove lorri garbage collection roots that point to removed shell.nix files - #[structopt(name = "gc")] Gc(GcOptions), /// Show information about a lorri project - #[structopt(name = "info")] Info(InfoOptions), /// Open a new project shell - #[structopt(name = "shell")] Shell(ShellOptions), /// Build project whenever an input file changes - #[structopt(name = "watch")] Watch(WatchOptions), /// Start the multi-project daemon. Replaces `lorri watch` - #[structopt(name = "daemon")] Daemon(DaemonOptions), /// Upgrade Lorri - #[structopt(name = "self-upgrade", alias = "self-update")] + #[command(name = "self-upgrade", alias = "self-update")] Upgrade(UpgradeTo), /// Write bootstrap files to current directory to create a new lorri project - #[structopt(name = "init")] Init, /// Internal commands, only use to experiment with unstable features - #[structopt(name = "internal")] Internal { /// Sub-command to execute - #[structopt(subcommand)] + #[command(subcommand)] command: Internal_, }, } /// Common options about the build source, defaults to `shell.nix` -#[derive(StructOpt, Debug, Clone)] +#[derive(Parser, Debug, Clone)] pub struct DefaultingSourceOptions { /// The .nix file in the current directory to use - #[structopt(long = "shell-file", parse(from_os_str))] + #[arg(long)] pub shell_file: Option, /// The path to consider a flake source within - #[structopt( - long = "context", - parse(from_os_str), - default_value = ".", - conflicts_with = "nix_file" - )] + #[arg(long = "context", default_value = ".", conflicts_with = "shell_file")] pub context_dir: PathBuf, /// The installable descriptor for a flake - #[structopt(long = "flake", conflicts_with = "nix_file")] + #[arg(long, conflicts_with = "shell_file")] pub flake: Option, } @@ -108,10 +97,12 @@ fn from_current_dir(rel: &PathBuf) -> Result { AbsDirPathBuf::current_dir()? .relative_to(rel.clone()) .map_err(|err| { - clap::Error::with_description( - &format!("could not make {:?} absolute: {:?}", rel, err), - clap::ErrorKind::ValueValidation, - ) + let mut e = clap::error::Error::new(clap::error::ErrorKind::ValueValidation); + e.insert( + clap::error::ContextKind::InvalidValue, + ContextValue::String(format!("could not make {:?} absolute: {:?}", rel, err)), + ); + e }) } @@ -120,21 +111,27 @@ impl TryFrom for ProjectFile { fn try_from(opts: DefaultingSourceOptions) -> Result { match (opts.shell_file, opts.flake) { - (Some(_), Some(_)) => Err(clap::Error::with_description( - "cannot use nix-shell files and flakes together", - clap::ErrorKind::ArgumentConflict, - )), + (Some(_), Some(_)) => { + let mut e = clap::Error::new(clap::error::ErrorKind::ArgumentConflict); + e.insert( + clap::error::ContextKind::Suggested, + ContextValue::String( + "cannot use nix-shell files and flakes together".to_string(), + ), + ); + Err(e) + } // XXX Consider more sophisticated default - e.g. first that exists: shell.nix, flake.nix, default.nix (None, None) => find_nix_file("shell.nix") .or_else(|| find_nix_file("flake.nix")) .or_else(|| find_nix_file("default.nix")) - .ok_or_else(|| clap::Error::with_description( - &format!( - "No default build sources found\n\ + .ok_or_else(|| { + let mut e = clap::error::Error::new(clap::error::ErrorKind::ValueValidation); + e.insert(clap::error::ContextKind::Suggested, ContextValue::String(format!( "No default build sources found\n\ You can use a flake.nix file or the following minimal `shell.nix` to get started:\n\n\ - {}", - TRIVIAL_SHELL_SRC - ), clap::ErrorKind::ValueValidation)), + {}", TRIVIAL_SHELL_SRC))); + e + }), (Some(shell), None) => Ok(ProjectFile::ShellNix(from_current_dir(&shell)?.into())), (None, Some(flake)) => Ok(ProjectFile::FlakeNix(Installable { context: from_current_dir(&opts.context_dir)?, @@ -183,23 +180,18 @@ fn find_nix_file(shellfile: &str) -> Option { /// This version of the source options has no default value. That's on purpose: sometimes the user /// will have projects with multiple shell files. This way, they are forced to think about which shell /// file was causing problems when they submit a bug report. -#[derive(StructOpt, Debug, Clone)] +#[derive(Parser, Debug, Clone)] pub struct SourceOptions { /// The .nix file in the current directory to use - #[structopt(long = "shell-file", parse(from_os_str))] + #[arg(long)] pub shell_file: Option, /// The path to consider a flake source within - #[structopt( - long = "context", - parse(from_os_str), - default_value = ".", - conflicts_with = "nix_file" - )] + #[arg(long = "context", default_value = ".", conflicts_with = "shell_file")] pub context_dir: PathBuf, /// The installable descriptor for a flake - #[structopt(long = "flake", conflicts_with = "nix_file")] + #[arg(long = "flake", conflicts_with = "shell_file")] pub flake: Option, } @@ -208,14 +200,25 @@ impl TryFrom for ProjectFile { fn try_from(opts: SourceOptions) -> Result { match (opts.shell_file, opts.flake) { - (Some(_), Some(_)) => Err(clap::Error::with_description( - "cannot use nix-shell files and flakes together", - clap::ErrorKind::ArgumentConflict, - )), - (None, None) => Err(clap::Error::with_description( - "either --shell-file or --flake is required", - clap::ErrorKind::MissingRequiredArgument, - )), + (Some(_), Some(_)) => { + let mut e = clap::error::Error::new(clap::error::ErrorKind::ArgumentConflict); + e.insert( + ContextKind::InvalidValue, + ContextValue::String( + "cannot use nix-shell files and flakes together".to_string(), + ), + ); + Err(e) + } + (None, None) => { + let mut e = + clap::error::Error::new(clap::error::ErrorKind::MissingRequiredArgument); + e.insert( + ContextKind::SuggestedArg, + ContextValue::String("either --shell-file or --flake is required".to_string()), + ); + Err(e) + } (Some(shell), None) => Ok(ProjectFile::ShellNix(from_current_dir(&shell)?.into())), (None, Some(flake)) => Ok(ProjectFile::FlakeNix(Installable { context: from_current_dir(&opts.context_dir)?, @@ -226,18 +229,18 @@ impl TryFrom for ProjectFile { } /// Options for the `direnv` subcommand. -#[derive(StructOpt, Debug)] +#[derive(Parser, Debug)] pub struct DirenvOptions { #[allow(missing_docs)] - #[structopt(flatten)] + #[command(flatten)] pub source: DefaultingSourceOptions, } /// Options for the `info` subcommand. -#[derive(StructOpt, Debug)] +#[derive(Parser, Debug)] pub struct InfoOptions { #[allow(missing_docs)] - #[structopt(flatten)] + #[command(flatten)] pub source: SourceOptions, } @@ -296,83 +299,84 @@ fn test_human_friendly_duration() { } /// Options for the `gc` subcommand. -#[derive(StructOpt, Debug)] +#[derive(Parser, Debug)] pub struct GcOptions { /// Machine readable output - #[structopt(long)] + #[arg(long)] pub json: bool, - #[structopt(subcommand)] + #[command(subcommand)] /// Subcommand for lorri gc pub action: GcSubcommand, } -#[derive(Debug, StructOpt)] +#[derive(Subcommand, Debug)] /// Subcommand for lorri gc pub enum GcSubcommand { /// Prints the gc roots that lorri created. - #[structopt(name = "info")] Info, /// Removes the gc roots associated to projects whose nix file vanished. - #[structopt(name = "rm")] Rm { /// Also delete the root associated with these shell files - #[structopt(long = "shell-file")] + // #[arg(long = "shell-file")] + #[arg(long)] shell_file: Vec, /// Delete the root of all projects - #[structopt(long)] + #[arg(long)] all: bool, /// Also delete the root of projects that were last built before this amount of time, e.g. 30d. - #[structopt(long = "older-than", parse(try_from_str = "human_friendly_duration"))] + #[arg(long = "older-than", value_parser = clap::builder::ValueParser::new(human_friendly_duration))] older_than: Option, }, } /// Options for the `shell` subcommand. -#[derive(StructOpt, Debug)] +#[derive(Parser, Debug)] pub struct ShellOptions { // The source to build the environment from #[allow(missing_docs)] - #[structopt(flatten)] + #[command(flatten)] pub source: DefaultingSourceOptions, /// If true, load environment from cache - #[structopt(long = "cached")] + #[arg(long)] pub cached: bool, } /// Options for the `internal start-user-shell` subcommand. -#[derive(StructOpt, Debug)] +#[derive(Parser, Debug)] pub struct StartUserShellOptions_ { /// The path of the parent shell's binary - #[structopt(long = "shell-path", parse(from_os_str))] + #[arg(long)] pub shell_path: PathBuf, // The source to build the environment from + // #[allow(missing_docs)] #[allow(missing_docs)] - #[structopt(flatten)] + #[command(flatten)] pub source: DefaultingSourceOptions, } /// Options for the `watch` subcommand. -#[derive(StructOpt, Debug)] +#[derive(Parser, Debug)] pub struct WatchOptions { // The source to build the environment from #[allow(missing_docs)] - #[structopt(flatten)] + #[command(flatten)] pub source: DefaultingSourceOptions, /// Exit after a the first build - #[structopt(long = "once")] + #[arg(long)] pub once: bool, } /// Options for the `daemon` subcommand -#[derive(StructOpt, Debug)] +#[derive(Parser, Debug)] pub struct DaemonOptions { - #[structopt( - long = "extra-nix-options", - parse(try_from_str = "serde_json::from_str") - )] + // #[arg( + // long = "extra-nix-options", + // parse(try_from_str = "serde_json::from_str") + // )] + #[arg(long)] /// JSON value of nix config options to add. /// Only a subset is supported: /// { @@ -383,7 +387,7 @@ pub struct DaemonOptions { } /// The nix options we can parse as json string -#[derive(Deserialize, Debug)] +#[derive(Deserialize, Debug, Clone)] // ATTN: If you modify this, // adjust the help text in DaemonOptions.extra_nix_options pub struct NixOptions { @@ -393,15 +397,21 @@ pub struct NixOptions { pub substituters: Option>, } +impl FromStr for NixOptions { + type Err = serde_json::Error; + + fn from_str(s: &str) -> Result { + serde_json::from_str(s) + } +} + /// Sub-commands which lorri can execute for internal features -#[derive(StructOpt, Debug)] +#[derive(Subcommand, Debug)] pub enum Internal_ { /// (internal) Used internally by `lorri shell` - #[structopt(name = "start-user-shell")] StartUserShell_(StartUserShellOptions_), /// (plumbing) Tell the lorri daemon to care about the current directory's project - #[structopt(name = "ping")] Ping_(Ping_), /// (experimental) Ask the lorri daemon to report build events as they occur. @@ -410,7 +420,6 @@ pub enum Internal_ { /// so if you want to use it in your scripts make sure you follow our changes. /// Once it stabilizes a bit more we will start mentioning changes in the changelog, /// and eventually ensure backwards compat. - #[structopt(name = "stream-events")] StreamEvents_(StreamEvents_), } @@ -419,68 +428,63 @@ pub enum Internal_ { /// Pinging with a project tells the daemon that the project was recently interacted with. /// If the daemon has not been pinged for a project, it begins listening. If it does not /// get pinged for a long time, it may stop watching the project for changes. -#[derive(StructOpt, Debug)] +#[derive(Parser, Debug)] pub struct Ping_ { #[allow(missing_docs)] - #[structopt(flatten)] + #[command(flatten)] pub source: DefaultingSourceOptions, } /// Stream events from the daemon. -#[derive(StructOpt, Debug)] +#[derive(Parser, Debug)] pub struct StreamEvents_ { - #[structopt(long, default_value = "all")] + #[arg(long, default_value = "all")] /// The kind of events to report pub kind: crate::ops::EventKind, } /// A stub struct to represent how what we want to upgrade to. -#[derive(StructOpt, Debug)] +#[derive(Parser, Debug)] #[structopt(name = "basic")] pub struct UpgradeTo { /// Where to upgrade to. If no subcommand given, `rolling-release` is assumed. - #[structopt(subcommand)] + #[command(subcommand)] pub source: Option, } /// Version-specifiers of different upgrade targets. -#[derive(StructOpt, Debug)] +#[derive(Subcommand, Debug)] pub enum UpgradeSource { /// Upgrade to the current rolling-release version, will be /// fetched from git and built locally. rolling-release is /// expected to be more stable than canon. (default) - #[structopt(name = "rolling-release")] RollingRelease, /// Upgrade to the current version from the canon (previously: master) branch, /// which will be fetched from git and built locally. - #[structopt(name = "canon")] Canon, /// Alias for `canon`. - #[structopt(name = "master")] Master, /// Upgrade to the specified git branch, which will be fetched /// and built locally. - #[structopt(name = "branch")] Branch(BranchDest), /// Upgrade to a version in an arbitrary local directory. - #[structopt(name = "local")] Local(LocalDest), } /// Install an arbitrary version of lorri from a local directory. -#[derive(StructOpt, Debug)] +#[derive(Parser, Debug)] pub struct LocalDest { /// the path to a local check out of lorri. - #[structopt(parse(from_os_str))] + #[arg(long)] pub path: PathBuf, } /// Install an arbitrary version of Lorri from an upstream git branch. -#[derive(StructOpt, Debug)] +#[derive(Parser, Debug)] pub struct BranchDest { /// the path to git branch of the upstream repository. pub branch: String, diff --git a/src/lib.rs b/src/lib.rs index 8e5d7b2..97daa3a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,8 +11,6 @@ // triggered by select (TODO: fixed in crossbeam_channel 0.5) #![allow(dropping_copy_types, clippy::zero_ptr)] -#[macro_use] -extern crate structopt; #[macro_use] extern crate serde_derive; diff --git a/src/main.rs b/src/main.rs index a7d1ff8..7d8e365 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +use clap::Parser; use lorri::cli::{Arguments, Command, Internal_, Verbosity}; use lorri::ops; use lorri::ops::error::ExitError; @@ -7,7 +8,6 @@ use lorri::{logging, AbsDirPathBuf}; use slog::{debug, error, o}; use std::env; use std::path::Path; -use structopt::StructOpt; use anyhow::anyhow; const TRIVIAL_SHELL_SRC: &str = include_str!("./trivial-shell.nix"); @@ -17,7 +17,7 @@ fn main() { install_panic_handler(); let exit_code = { - let opts = Arguments::from_args(); + let opts = Arguments::parse(); let verbosity = match opts.verbosity { // -v flag was given 0 times diff --git a/src/ops.rs b/src/ops.rs index a1937c1..4380ca9 100644 --- a/src/ops.rs +++ b/src/ops.rs @@ -609,7 +609,7 @@ PS1="(lorri) ${PS1}" } /// Options for the kinds of events to report -#[derive(Debug)] +#[derive(Debug, Clone)] pub enum EventKind { /// Report only live events - those that happen after invocation Live, diff --git a/src/ops/error.rs b/src/ops/error.rs index e295e70..5b4c607 100644 --- a/src/ops/error.rs +++ b/src/ops/error.rs @@ -1,6 +1,6 @@ //! Exit errors returned from an op. -use structopt::clap; +use clap; /// Non-zero exit status from an op. /// @@ -115,8 +115,8 @@ impl From for ExitError { } } -impl From for ExitError { - fn from(err: clap::Error) -> Self { +impl From for ExitError { + fn from(err: clap::error::Error) -> Self { ExitError::user_error(err) } }