diff options
-rw-r--r-- | Cargo.lock | 220 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | src/args.rs | 56 |
4 files changed, 96 insertions, 184 deletions
@@ -27,15 +27,6 @@ dependencies = [ ] [[package]] -name = "ansi_term" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -dependencies = [ - "winapi", -] - -[[package]] name = "anstream" version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -85,17 +76,6 @@ dependencies = [ ] [[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi", -] - -[[package]] name = "autocfg" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -117,12 +97,6 @@ dependencies = [ [[package]] name = "bitflags" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" - -[[package]] -name = "bitflags" version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" @@ -135,20 +109,46 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "2.33.3" +version = "4.5.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" dependencies = [ - "ansi_term", - "atty", - "bitflags 1.2.1", + "anstream", + "anstyle", + "clap_lex", "strsim", - "textwrap", - "unicode-width", - "vec_map", + "terminal_size", +] + +[[package]] +name = "clap_derive" +version = "4.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.87", ] [[package]] +name = "clap_lex" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" + +[[package]] name = "color-eyre" version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -276,21 +276,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "heck" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" -dependencies = [ - "unicode-segmentation", -] - -[[package]] -name = "hermit-abi" -version = "0.1.18" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" -dependencies = [ - "libc", -] +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "humantime" @@ -337,7 +325,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.6.0", + "bitflags", "libc", ] @@ -357,6 +345,7 @@ checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" name = "makers" version = "0.7.0" dependencies = [ + "clap", "dirs", "env_logger", "eyre", @@ -366,7 +355,6 @@ dependencies = [ "log", "nom", "regex", - "structopt", "tempfile", ] @@ -433,43 +421,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905" [[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - -[[package]] name = "proc-macro2" -version = "1.0.24" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] name = "quote" -version = "1.0.9" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -526,7 +490,7 @@ version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ - "bitflags 2.6.0", + "bitflags", "errno", "libc", "linux-raw-sys", @@ -544,43 +508,30 @@ dependencies = [ [[package]] name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - -[[package]] -name = "structopt" -version = "0.3.26" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" -dependencies = [ - "clap", - "lazy_static", - "structopt-derive", -] +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] -name = "structopt-derive" -version = "0.4.18" +name = "syn" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "heck", - "proc-macro-error", "proc-macro2", "quote", - "syn", + "unicode-ident", ] [[package]] name = "syn" -version = "1.0.64" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fd9d1e9976102a03c542daa2eff1b43f9d72306342f3f8b3ed5fb8908195d6f" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", ] [[package]] @@ -597,12 +548,13 @@ dependencies = [ ] [[package]] -name = "textwrap" -version = "0.11.0" +name = "terminal_size" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +checksum = "4f599bd7ca042cfdf8f4512b277c02ba102247820f9d9d4a9f521f496751a6ef" dependencies = [ - "unicode-width", + "rustix", + "windows-sys 0.59.0", ] [[package]] @@ -622,7 +574,7 @@ checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -654,7 +606,7 @@ checksum = "c42e6fa53307c8a17e4ccd4dc81cf5ec38db9209f59b222210375b54ee40d1e2" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -688,22 +640,10 @@ dependencies = [ ] [[package]] -name = "unicode-segmentation" -version = "1.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" - -[[package]] -name = "unicode-width" -version = "0.1.8" +name = "unicode-ident" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" - -[[package]] -name = "unicode-xid" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "utf8parse" @@ -712,46 +652,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - -[[package]] -name = "version_check" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" - -[[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] name = "windows-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -15,6 +15,7 @@ default = ['full'] full = ['dirs', 'glob'] [dependencies] +clap = { version = "4.5.20", features = ["derive", "wrap_help"] } dirs = { version = "5.0.1", optional = true } env_logger = "0.11.5" eyre = "0.6.12" @@ -24,7 +25,6 @@ lazy_static = "1.5.0" log = "0.4.22" nom = "7.1.3" regex = "1.11.0" -structopt = "0.3.26" [dev-dependencies] tempfile = "3.13.0" @@ -31,7 +31,7 @@ specific projects tested: list of features that are needed for version 1.0: -- moved from structopt to clap 4 +- actual documentation - tested with Linux - unit tests for most of the things - no TODOs left diff --git a/src/args.rs b/src/args.rs index 9318202..b4e6f84 100644 --- a/src/args.rs +++ b/src/args.rs @@ -3,15 +3,15 @@ use std::ffi::OsString; use std::iter; use std::path::PathBuf; -use structopt::StructOpt; +use clap::Parser; -#[derive(StructOpt, Debug, PartialEq, Eq, Clone)] -#[structopt(author, about)] +#[derive(clap::Parser, Debug, PartialEq, Eq, Clone)] +#[clap(author, about)] #[allow(clippy::struct_excessive_bools)] pub struct Args { /// Cause environment variables, including those with null values, to override macro /// assignments within makefiles. - #[structopt(short, long)] + #[clap(short, long)] pub environment_overrides: bool, /// Specify a different makefile (or '-' for standard input). @@ -21,12 +21,12 @@ pub struct Args { /// be multiple instances of this option, and they shall be processed in the order /// specified. The effect of specifying the same option-argument more than once is /// unspecified. - #[structopt( - short = "f", + #[clap( + short = 'f', long = "file", visible_alias = "makefile", number_of_values = 1, - parse(from_os_str) + value_parser )] pub makefile: Vec<PathBuf>, @@ -34,17 +34,17 @@ pub struct Args { /// /// This mode is the same as if the special target .IGNORE were specified without /// prerequisites. - #[structopt(short, long)] + #[clap(short, long)] pub ignore_errors: bool, /// Continue to update other targets that do not depend on the current target if a /// non-ignored error occurs while executing the commands to bring a target /// up-to-date. - #[structopt( + #[clap( short, long, - overrides_with = "keep-going", - overrides_with = "no-keep-going" + overrides_with = "keep_going", + overrides_with = "no_keep_going" )] pub keep_going: bool, @@ -54,8 +54,8 @@ pub struct Args { /// However, lines with a <plus-sign> ( '+' ) prefix shall be executed. In this mode, /// lines with an at-sign ( '@' ) character prefix shall be written to standard /// output. - #[structopt( - short = "n", + #[clap( + short = 'n', long, visible_alias = "just-print", visible_alias = "recon" @@ -66,7 +66,7 @@ pub struct Args { /// descriptions. /// /// The output format is unspecified. - #[structopt(short, long, visible_alias = "print-data-base")] + #[clap(short, long, visible_alias = "print-data-base")] pub print_everything: bool, /// Return a zero exit value if the target file is up-to-date; otherwise, return an @@ -75,11 +75,11 @@ pub struct Args { /// Targets shall not be updated if this option is specified. However, a makefile /// command line (associated with the targets) with a <plus-sign> ( '+' ) prefix /// shall be executed. - #[structopt(short, long)] + #[clap(short, long)] pub question: bool, /// Clear the suffix list and do not use the built-in rules. - #[structopt(short = "r", long)] + #[clap(short = 'r', long)] pub no_builtin_rules: bool, /// Terminate make if an error occurs while executing the commands to bring a target @@ -87,13 +87,13 @@ pub struct Args { /// reason). /// /// This shall be the default and the opposite of -k. - #[structopt( - short = "S", + #[clap( + short = 'S', long, visible_alias = "stop", - hidden = true, - overrides_with = "keep-going", - overrides_with = "no-keep-going" + hide = true, + overrides_with = "keep_going", + overrides_with = "no_keep_going" )] pub no_keep_going: bool, @@ -102,7 +102,7 @@ pub struct Args { /// /// This mode shall be the same as if the special target .SILENT were specified /// without prerequisites. - #[structopt(short, long, visible_alias = "quiet")] + #[clap(short, long, visible_alias = "quiet")] pub silent: bool, /// Update the modification time of each target as though a touch target had been @@ -113,12 +113,12 @@ pub struct Args { /// target file indicating the name of the file and that it was touched. Normally, /// the makefile command lines associated with each target are not executed. However, /// a command line with a <plus-sign> ( '+' ) prefix shall be executed. - #[structopt(short, long)] + #[clap(short, long)] pub touch: bool, /// Change to the given directory before running. #[cfg(feature = "full")] - #[structopt(short = "C", long, parse(from_os_str))] + #[clap(short = 'C', long, value_parser)] pub directory: Option<PathBuf>, /// Target names or macro definitions. @@ -161,7 +161,7 @@ impl Args { .chain(env_makeflags.into_iter()) .chain(args); - Self::from_iter(args) + Self::parse_from(args) } pub fn from_env_and_args() -> Self { @@ -232,6 +232,12 @@ mod test { use super::*; #[test] + fn clap_validate() { + use clap::CommandFactory; + Args::command().debug_assert(); + } + + #[test] fn no_args() { let args: Vec<OsString> = vec!["makers".into()]; let args = Args::from_given_args_and_given_env(args.into_iter(), String::new()); |