From 29edcdd7eeda965c34fae2d6903cab4be99d1cd3 Mon Sep 17 00:00:00 2001 From: tmorin Date: Mon, 20 Mar 2023 21:23:20 +0100 Subject: [PATCH] chore: upgrade clap from 3.2 to 4.1 --- Cargo.lock | 118 +++++++++++++++----------------- Cargo.toml | 4 +- src/app.rs | 11 ++- src/cli.rs | 42 ++++++++---- src/cmd/diagram/generate/mod.rs | 2 +- 5 files changed, 89 insertions(+), 88 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c6fad9d..35de5bc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -26,17 +26,6 @@ dependencies = [ "libc", ] -[[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.1.0" @@ -67,6 +56,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "487f1e0fcbe47deb8b0574e646def1c903389d95241dd1bbcc6ce4a715dfc0c1" + [[package]] name = "block-buffer" version = "0.10.4" @@ -167,34 +162,32 @@ dependencies = [ [[package]] name = "clap" -version = "3.2.23" +version = "4.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" +checksum = "42dfd32784433290c51d92c438bb72ea5063797fc3cc9a21a8c4346bebbb2098" dependencies = [ - "atty", - "bitflags 1.3.2", + "bitflags 2.0.2", "clap_lex", - "indexmap", + "is-terminal", "once_cell", "strsim", "termcolor", - "textwrap", ] [[package]] name = "clap_complete" -version = "3.2.5" +version = "4.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f7a2e0a962c45ce25afce14220bc24f9dade0a1787f185cecf96bfba7847cd8" +checksum = "37686beaba5ac9f3ab01ee3172f792fc6ffdd685bfb9e63cfef02c0571a4e8e1" dependencies = [ "clap", ] [[package]] name = "clap_lex" -version = "0.2.4" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +checksum = "033f6b7a4acb1f358c742aaca805c939ee73b4c6209ae4318ec7aca81c42e646" dependencies = [ "os_str_bytes", ] @@ -332,7 +325,7 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.0", + "syn 2.0.3", ] [[package]] @@ -349,7 +342,7 @@ checksum = "631569015d0d8d54e6c241733f944042623ab6df7bc3be7466874b05fcdb1c5f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.0", + "syn 2.0.3", ] [[package]] @@ -683,15 +676,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hermit-abi" version = "0.2.6" @@ -900,9 +884,9 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "1.0.7" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76e86b86ae312accbf05ade23ce76b625e0e47a255712b7414037385a1c05380" +checksum = "09270fd4fa1111bc614ed2246c7ef56239a3063d5be0d1ec3b589c505d400aeb" dependencies = [ "hermit-abi 0.3.1", "libc", @@ -915,6 +899,18 @@ version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146" +[[package]] +name = "is-terminal" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8687c819457e979cc940d09cb16e42a1bf70aa6b60a549de6d3a62a0ee90c69e" +dependencies = [ + "hermit-abi 0.3.1", + "io-lifetimes", + "rustix", + "windows-sys 0.45.0", +] + [[package]] name = "itoa" version = "1.0.6" @@ -1029,9 +1025,9 @@ dependencies = [ [[package]] name = "mime" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "miniz-sys" @@ -1183,9 +1179,9 @@ checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "openssl" -version = "0.10.46" +version = "0.10.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd2523381e46256e40930512c7fd25562b9eae4812cb52078f155e87217c9d1e" +checksum = "d8b277f87dacc05a6b709965d1cbafac4649d6ce9f3ce9ceb88508b5666dfec9" dependencies = [ "bitflags 1.3.2", "cfg-if", @@ -1215,18 +1211,18 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-src" -version = "111.25.1+1.1.1t" +version = "111.25.2+1.1.1t" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ef9a9cc6ea7d9d5e7c4a913dc4b48d0e359eddf01af1dfec96ba7064b4aba10" +checksum = "320708a054ad9b3bf314688b5db87cf4d6683d64cfc835e2337924ae62bf4431" dependencies = [ "cc", ] [[package]] name = "openssl-sys" -version = "0.9.81" +version = "0.9.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176be2629957c157240f68f61f2d0053ad3a4ecfdd9ebf1e6521d18d9635cf67" +checksum = "a95792af3c4e0153c3914df2261bedd30a98476f94dc892b67dfe1d89d433a04" dependencies = [ "autocfg", "cc", @@ -1238,9 +1234,9 @@ dependencies = [ [[package]] name = "os_str_bytes" -version = "6.4.1" +version = "6.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" +checksum = "ceedf44fb00f2d1984b0bc98102627ce622e083e49a5bacdb3e514fa4238e267" [[package]] name = "parse-zoneinfo" @@ -1575,9 +1571,9 @@ checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" [[package]] name = "reqwest" -version = "0.11.14" +version = "0.11.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21eed90ec8570952d53b772ecf8f206aa1ec9a3d76b2521c56c42973f2d91ee9" +checksum = "0ba30cc2c0cd02af1222ed216ba659cdb2f879dfe3181852fe7c50b1d0005949" dependencies = [ "base64", "bytes", @@ -1618,9 +1614,9 @@ checksum = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" [[package]] name = "rustix" -version = "0.36.9" +version = "0.36.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc" +checksum = "db4165c9963ab29e422d6c26fbc1d37f15bace6b2810221f9d925023480fcf0e" dependencies = [ "bitflags 1.3.2", "errno", @@ -1697,22 +1693,22 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.157" +version = "1.0.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707de5fcf5df2b5788fca98dd7eab490bc2fd9b7ef1404defc462833b83f25ca" +checksum = "771d4d9c4163ee138805e12c710dd365e4f44be8be0503cb1bb9eb989425d9c9" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.157" +version = "1.0.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78997f4555c22a7971214540c4a661291970619afd56de19f77e0de86296e1e5" +checksum = "e801c1712f48475582b7696ac71e0ca34ebb30e09338425384269d9717c62cad" dependencies = [ "proc-macro2", "quote", - "syn 2.0.0", + "syn 2.0.3", ] [[package]] @@ -1836,9 +1832,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.0" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cff13bb1732bccfe3b246f3fdb09edfd51c01d6f5299b7ccd9457c2e4e37774" +checksum = "e8234ae35e70582bfa0f1fedffa6daa248e41dd045310b19800c4a36382c8f60" dependencies = [ "proc-macro2", "quote", @@ -1890,12 +1886,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "textwrap" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" - [[package]] name = "thiserror" version = "1.0.40" @@ -1913,7 +1903,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.0", + "syn 2.0.3", ] [[package]] @@ -2108,9 +2098,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.12" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d502c968c6a838ead8e69b2ee18ec708802f99db92a0d156705ec9ef801993b" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" diff --git a/Cargo.toml b/Cargo.toml index fe27a86..4f16f4b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,8 +23,8 @@ name = "plantuml-generator" [dependencies] chrono = "0.4" -clap_complete = "3.2" -clap = { version = "3.2", features = ["env", "cargo"] } +clap_complete = "4.1" +clap = { version = "4.1", features = ["env", "cargo"] } env_logger = { version = "0.10.0", default_features = false } glob = "0.3" heck = "0.4" diff --git a/src/app.rs b/src/app.rs index 9d22bd5..831c159 100644 --- a/src/app.rs +++ b/src/app.rs @@ -14,7 +14,7 @@ where I: IntoIterator, T: Into + Clone, { - let app = build_cli(); + let mut app = build_cli(); let app_matches = match app.clone().try_get_matches_from(args) { Ok(app_matches) => app_matches, @@ -55,8 +55,7 @@ where } _ => { log::warn!("the SUBCOMMAND is missing"); - app.clone() - .write_help(&mut io::stderr()) + app.write_help(&mut io::stderr()) .expect("unable to write help message"); eprintln!(); 2 @@ -74,8 +73,7 @@ where } _ => { log::warn!("the SUBCOMMAND is missing"); - app.clone() - .write_help(&mut io::stderr()) + app.write_help(&mut io::stderr()) .expect("unable to write help message"); eprintln!(); 2 @@ -96,8 +94,7 @@ where } _ => { log::warn!("the SUBCOMMAND is missing"); - app.clone() - .write_help(&mut io::stderr()) + app.write_help(&mut io::stderr()) .expect("unable to write help message"); eprintln!(); 2 diff --git a/src/cli.rs b/src/cli.rs index 53b6a21..c34e0a8 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -4,11 +4,12 @@ use clap::{ }; use clap_complete::Shell; -pub fn build_cli() -> Command<'static> { +pub fn build_cli() -> Command { let arg_cache_directory: Arg = Arg::new("cache_directory") .short('C') .long("cache") - .takes_value(true) + .action(ArgAction::Set) + .num_args(1) .env("PLANTUML_GENERATOR_OUTPUT_CACHE") .help("The cache directory."); @@ -16,7 +17,8 @@ pub fn build_cli() -> Command<'static> { .conflicts_with("plantuml_jar") .short('V') .long("plantuml-version") - .takes_value(true) + .action(ArgAction::Set) + .num_args(1) .env("PLANTUML_GENERATOR_PLANTUML_VERSION") .help("The PlantUML version."); @@ -24,21 +26,24 @@ pub fn build_cli() -> Command<'static> { .conflicts_with("plantuml_version") .short('P') .long("plantuml") - .takes_value(true) + .action(ArgAction::Set) + .num_args(1) .env("PLANTUML_GENERATOR_PLANTUML_JAR") .help("The PlantUML version."); let arg_java_binary: Arg = Arg::new("java_binary") .short('J') .long("java") - .takes_value(true) + .action(ArgAction::Set) + .num_args(1) .env("PLANTUML_GENERATOR_JAVA_BINARY") .help("The java binary path or command line."); let arg_inkscape_binary: Arg = Arg::new("inkscape_binary") .short('I') .long("inkscape") - .takes_value(true) + .action(ArgAction::Set) + .num_args(1) .env("PLANTUML_GENERATOR_INKSCAPE_BINARY") .help("The inkscape binary path or command line."); @@ -52,7 +57,8 @@ pub fn build_cli() -> Command<'static> { Arg::new("log_level") .short('l') .long("log-level") - .takes_value(true) + .action(ArgAction::Set) + .num_args(1) .default_value("Info") .value_parser(PossibleValuesParser::new(["Off", "Trace", "Debug", "Info", "Warn", "Error"])) .help("Set the verbosity of the logs."), @@ -68,31 +74,36 @@ pub fn build_cli() -> Command<'static> { .arg(Arg::new("MANIFEST") .index(1) .required(true) - .takes_value(true) + .action(ArgAction::Set) + .num_args(1) .help("The manifest of the library.") ) .arg(Arg::new("output_directory") .short('O') .long("output") .env("PLANTUML_GENERATOR_OUTPUT_DIRECTORY") - .takes_value(true) + .action(ArgAction::Set) + .num_args(1) .help("The output directory.") ) .arg(Arg::new("urns") .help("Handle only artifacts included in the URN.") .short('u') .long("urn") - .takes_value(true) + .action(ArgAction::Set) + .num_args(1) .action(ArgAction::Append) .value_parser(ValueParser::string()) ) .arg(Arg::new("do_clean_cache") .long("clean-cache") + .action(ArgAction::SetTrue) .help("Delete the cache directory before the generation-")) .arg(Arg::new("urns_to_clean") .help("Delete the given URN in the output directory before the generation.") .long("clean-urn") - .takes_value(true) + .action(ArgAction::Set) + .num_args(1) .action(ArgAction::Append) .value_parser(ValueParser::string()) ) @@ -101,7 +112,8 @@ pub fn build_cli() -> Command<'static> { .long_help("By default, artifacts which are already generated won't be generated again. The cleanup-scope option helps to target artifacts which will be re-generated.") .short('c') .long("cleanup-scope") - .takes_value(true) + .action(ArgAction::Set) + .num_args(1) .action(ArgAction::Append) .value_parser(PossibleValuesParser::new([ "All", @@ -136,7 +148,8 @@ pub fn build_cli() -> Command<'static> { .short('s') .long("source") .default_value(".") - .takes_value(true) + .action(ArgAction::Set) + .num_args(1) .env("PLANTUML_GENERATOR_SOURCE_DIRECTORY") .help("The directory where the .puml will be discovered.")) .arg(Arg::new("do_force_generation") @@ -156,7 +169,8 @@ pub fn build_cli() -> Command<'static> { Arg::new("SHELL") .help("set the shell") .index(1) - .takes_value(true) + .action(ArgAction::Set) + .num_args(1) .required(true) .value_parser(value_parser!(Shell)) ) diff --git a/src/cmd/diagram/generate/mod.rs b/src/cmd/diagram/generate/mod.rs index 0628f7a..efa9387 100644 --- a/src/cmd/diagram/generate/mod.rs +++ b/src/cmd/diagram/generate/mod.rs @@ -141,7 +141,7 @@ mod test { create_parent_directory(&to_path).unwrap(); std::fs::copy(&from_path, &to_path).unwrap(); } - let arg_matches = build_cli().get_matches_from(&[ + let arg_matches = build_cli().get_matches_from([ "plantuml-generator", "-l=Debug", "diagram",