From 84997dc896a0147e61ee1853d93d59e1ef2f4ba3 Mon Sep 17 00:00:00 2001 From: "Alexis (Poliorcetics) Bourget" Date: Fri, 23 Feb 2024 01:30:12 +0100 Subject: [PATCH] chore(deps): move to clap 4 --- Cargo.lock | 141 ++++++++++----------------------------------- Cargo.toml | 4 +- src/completions.rs | 8 +-- src/config.rs | 29 +++++----- tests/command.rs | 4 +- tests/fmt.rs | 4 +- 6 files changed, 55 insertions(+), 135 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1f9cb985ed..5aa62a2cc6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -91,12 +91,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - [[package]] name = "bitflags" version = "1.3.2" @@ -178,44 +172,47 @@ dependencies = [ "atty", "bitflags 1.3.2", "strsim 0.8.0", - "textwrap 0.11.0", + "textwrap", "unicode-width", "vec_map", ] [[package]] name = "clap" -version = "3.2.25" +version = "4.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" +checksum = "b230ab84b0ffdf890d5a10abdbc8b83ae1c4918275daea1ab8801f71536b2651" dependencies = [ - "atty", - "bitflags 1.3.2", + "clap_builder", +] + +[[package]] +name = "clap_builder" +version = "4.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +dependencies = [ + "anstream", + "anstyle", "clap_lex", - "indexmap", - "strsim 0.10.0", - "termcolor", + "strsim 0.11.0", "terminal_size", - "textwrap 0.16.1", ] [[package]] name = "clap_complete" -version = "3.2.5" +version = "4.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f7a2e0a962c45ce25afce14220bc24f9dade0a1787f185cecf96bfba7847cd8" +checksum = "885e4d7d5af40bfb99ae6f9433e292feac98d452dcb3ec3d25dfe7552b77da8c" dependencies = [ - "clap 3.2.25", + "clap 4.5.2", ] [[package]] name = "clap_lex" -version = "0.2.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" -dependencies = [ - "os_str_bytes", -] +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "colorchoice" @@ -441,12 +438,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - [[package]] name = "heck" version = "0.3.3" @@ -492,27 +483,6 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown", -] - -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi 0.3.5", - "libc", - "windows-sys 0.48.0", -] - [[package]] name = "itoa" version = "1.0.10" @@ -527,7 +497,7 @@ dependencies = [ "atty", "blake3", "camino", - "clap 3.2.25", + "clap 4.5.2", "clap_complete", "cradle", "ctrlc", @@ -596,12 +566,6 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" -[[package]] -name = "linux-raw-sys" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" - [[package]] name = "linux-raw-sys" version = "0.4.13" @@ -663,12 +627,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" -[[package]] -name = "os_str_bytes" -version = "6.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" - [[package]] name = "pretty_assertions" version = "1.4.0" @@ -826,20 +784,6 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" -[[package]] -name = "rustix" -version = "0.37.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" -dependencies = [ - "bitflags 1.3.2", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys 0.3.8", - "windows-sys 0.48.0", -] - [[package]] name = "rustix" version = "0.38.31" @@ -849,7 +793,7 @@ dependencies = [ "bitflags 2.4.2", "errno", "libc", - "linux-raw-sys 0.4.13", + "linux-raw-sys", "windows-sys 0.52.0", ] @@ -952,9 +896,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "strsim" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" [[package]] name = "structopt" @@ -1038,7 +982,7 @@ checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if", "fastrand", - "rustix 0.38.31", + "rustix", "windows-sys 0.52.0", ] @@ -1051,22 +995,13 @@ dependencies = [ "tempfile", ] -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - [[package]] name = "terminal_size" -version = "0.2.6" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e6bf6f19e9f8ed8d4048dc22981458ebcf406d67e94cd422e5ecd73d63b3237" +checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" dependencies = [ - "rustix 0.37.27", + "rustix", "windows-sys 0.48.0", ] @@ -1079,15 +1014,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "textwrap" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" -dependencies = [ - "terminal_size", -] - [[package]] name = "thiserror" version = "1.0.57" @@ -1196,7 +1122,7 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.31", + "rustix", "windows-sys 0.52.0", ] @@ -1216,15 +1142,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" -dependencies = [ - "winapi", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index 4983f647e1..fea4cd2f29 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,8 +22,8 @@ ansi_term = "0.12.0" atty = "0.2.0" blake3 = { version = "1.5.0", features = ["rayon", "mmap"] } camino = "1.0.4" -clap = { version = "3.0.0", features = ["wrap_help"] } -clap_complete = "3.0.0" +clap = { version = "4.0.0", features = ["wrap_help"] } +clap_complete = "4.0.0" ctrlc = { version = "3.1.1", features = ["termination"] } derivative = "2.0.0" dirs = "5.0.1" diff --git a/src/completions.rs b/src/completions.rs index 4a8bf33469..74d0eb5dbe 100644 --- a/src/completions.rs +++ b/src/completions.rs @@ -43,8 +43,8 @@ pub(crate) const ZSH_COMPLETION_REPLACEMENTS: &[(&str, &str)] = &[ r" local common=(", ), ( - r"'--set=[Override with ]:VARIABLE: :VARIABLE: ' \", - r"'--set=[Override with ]: :(_just_variables)' \", + r"'*--set=[Override with ]:VARIABLE: :VARIABLE: ' \", + r"'*--set=[Override with ]: :(_just_variables)' \", ), ( r"'()-s+[Show information about ]:RECIPE: ' \ @@ -204,8 +204,8 @@ pub(crate) const BASH_COMPLETION_REPLACEMENTS: &[(&str, &str)] = &[ ), (r" just)", r#" "$1")"#), ( - r"local i cur prev opts cmds", - r"local i cur prev words cword opts cmds", + r"local i cur prev opts cmd", + r"local i cur prev words cword opts cmd", ), ( r#" cur="${COMP_WORDS[COMP_CWORD]}" diff --git a/src/config.rs b/src/config.rs index a070ff8cb5..6a8de5c926 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,8 +1,8 @@ use { super::*, clap::{ - builder::PossibleValuesParser, value_parser, AppSettings, Arg, ArgAction, ArgGroup, ArgMatches, - Command, + builder::{styling::AnsiColor, PossibleValuesParser, Styles}, + value_parser, Arg, ArgAction, ArgGroup, ArgMatches, Command, }, }; @@ -139,14 +139,17 @@ mod arg { } impl Config { - pub(crate) fn app() -> Command<'static> { + pub(crate) fn app() -> Command { let app = Command::new(env!("CARGO_PKG_NAME")) .bin_name(env!("CARGO_PKG_NAME")) - .help_message("Print help information") - .version_message("Print version information") - .setting(AppSettings::ColoredHelp) - .setting(AppSettings::TrailingVarArg) .trailing_var_arg(true) + .styles( + Styles::styled() + .header(AnsiColor::Yellow.on_default()) + .usage(AnsiColor::Yellow.on_default()) + .literal(AnsiColor::Green.on_default()) + .placeholder(AnsiColor::Green.on_default()) + ) .arg( Arg::new(arg::CHECK) .long("check") @@ -255,7 +258,7 @@ impl Config { .long("set") .action(ArgAction::Append) .number_of_values(2) - .value_names(&["VARIABLE", "VALUE"]) + .value_names(["VARIABLE", "VALUE"]) .help("Override with "), ) .arg( @@ -326,7 +329,7 @@ impl Config { Arg::new(cmd::COMMAND) .long("command") .short('c') - .min_values(1) + .num_args(1..) .allow_hyphen_values(true) .action(ArgAction::Append) .value_parser(value_parser!(std::ffi::OsString)) @@ -339,7 +342,7 @@ impl Config { Arg::new(cmd::COMPLETIONS) .long("completions") .action(ArgAction::Append) - .min_values(1) + .num_args(1..) .value_name("SHELL") .value_parser(value_parser!(clap_complete::Shell)) .ignore_case(true) @@ -427,7 +430,7 @@ impl Config { .group(ArgGroup::new("SUBCOMMAND").args(cmd::ALL)) .arg( Arg::new(arg::ARGUMENTS) - .multiple_values(true) + .num_args(1..) .action(ArgAction::Append) .help("Overrides and recipe(s) to run, defaulting to the first recipe in the justfile"), ); @@ -1537,8 +1540,8 @@ mod tests { assert_eq!(error.kind(), clap::error::ErrorKind::ArgumentConflict); assert_eq!(error.context().collect::>(), vec![ (ContextKind::InvalidArg, &ContextValue::String("--show ".into())), - (ContextKind::PriorArg, &ContextValue::String("...".into())), - (ContextKind::Usage, &ContextValue::String("USAGE:\n just <--changelog|--choose|--command ...|--completions ...|--dump|--edit|--evaluate|--fmt|--init|--list|--show |--summary|--variables>".into())), + (ContextKind::PriorArg, &ContextValue::String("[ARGUMENTS]...".into())), + (ContextKind::Usage, &ContextValue::StyledStr("\u{1b}[33mUsage:\u{1b}[0m \u{1b}[32mjust\u{1b}[0m \u{1b}[32m--show\u{1b}[0m\u{1b}[32m \u{1b}[0m\u{1b}[32m\u{1b}[0m \u{1b}[32m[ARGUMENTS]...\u{1b}[0m".into())), ]); }, } diff --git a/tests/command.rs b/tests/command.rs index 4a956945d2..44bde24f56 100644 --- a/tests/command.rs +++ b/tests/command.rs @@ -40,9 +40,9 @@ test! { ", args: ("--command"), stderr: " - error: The argument '--command ...' requires a value but none was supplied + error: a value is required for '--command ...' but none was supplied - For more information try --help + For more information, try '--help'. ", status: 2, } diff --git a/tests/fmt.rs b/tests/fmt.rs index 0c5e16ff95..1d70a6f9ab 100644 --- a/tests/fmt.rs +++ b/tests/fmt.rs @@ -15,8 +15,8 @@ test! { name: check_without_fmt, justfile: "", args: ("--check"), - stderr_regex: "error: The following required arguments were not provided: - --fmt + stderr_regex: "error: the following required arguments were not provided: + --fmt (.|\\n)+", status: 2, }