From 8f1dc49039b110a8bd72c0e9e2bc1494ea3a8be0 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Fri, 17 Mar 2023 16:14:20 -0700 Subject: [PATCH] cargo: upgrade to clap 4.1 This includes some changes to error messages. Also, the Zsh shell completion script is now simpler to source. Fixes #1393. --- Cargo.lock | 22 +++++++++++----------- Cargo.toml | 6 +++--- README.md | 3 +-- tests/test_alias.rs | 14 +++++++------- tests/test_branch_command.rs | 4 ++-- tests/test_config_command.rs | 8 ++++---- tests/test_diff_command.rs | 8 ++++---- tests/test_edit_command.rs | 4 ++-- tests/test_global_opts.rs | 2 +- tests/test_log_command.rs | 8 ++++---- tests/test_move_command.rs | 4 ++-- tests/test_rebase_command.rs | 12 ++++++------ tests/test_untrack_command.rs | 4 ++-- 13 files changed, 49 insertions(+), 50 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dbeeb5a70..2d8deacf2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -230,9 +230,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.0.32" +version = "4.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7db700bc935f9e43e88d00b0850dae18a63773cfbec6d8e070fccf7fef89a39" +checksum = "9a9d6ada83c1edcce028902ea27dd929069c70df4c7600b131b4d9a1ad2879cc" dependencies = [ "bitflags", "clap_derive", @@ -245,18 +245,18 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.0.7" +version = "4.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10861370d2ba66b0f5989f83ebf35db6421713fd92351790e7fdd6c36774c56b" +checksum = "37686beaba5ac9f3ab01ee3172f792fc6ffdd685bfb9e63cfef02c0571a4e8e1" dependencies = [ - "clap 4.0.32", + "clap 4.1.9", ] [[package]] name = "clap_derive" -version = "4.0.21" +version = "4.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0177313f9f02afc995627906bbd8967e2be069f5261954222dac78290c2b9014" +checksum = "fddf67631444a3a3e3e5ac51c36a5e01335302de677bd78759eaa90ab1f46644" dependencies = [ "heck", "proc-macro-error", @@ -285,11 +285,11 @@ dependencies = [ [[package]] name = "clap_mangen" -version = "0.2.6" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904eb24d05ad587557e0f484ddce5c737c30cf81372badb16d13e41c4b8340b1" +checksum = "4237e29de9c6949982ba87d51709204504fb8ed2fd38232fcb1e5bf7d4ba48c8" dependencies = [ - "clap 4.0.32", + "clap 4.1.9", "roff", ] @@ -799,7 +799,7 @@ dependencies = [ "assert_cmd", "assert_matches", "chrono", - "clap 4.0.32", + "clap 4.1.9", "clap_complete", "clap_mangen", "config", diff --git a/Cargo.toml b/Cargo.toml index ca7a344c0..bdb926548 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,9 +35,9 @@ members = ["lib", "lib/testutils", "lib/gen-protos"] [dependencies] chrono = { version = "0.4.24", default-features = false, features = ["std", "clock"] } -clap = { version = "4.0.32", features = ["derive", "deprecated"] } -clap_complete = "4.0.7" -clap_mangen = "0.2.6" +clap = { version = "4.1.9", features = ["derive", "deprecated"] } +clap_complete = "4.1.5" +clap_mangen = "0.2.10" config = { version = "0.13.3", default-features = false, features = ["toml"] } crossterm = { version = "0.26", default-features = false } dirs = "4.0.0" diff --git a/README.md b/README.md index aaeb78fe1..6f90b3deb 100644 --- a/README.md +++ b/README.md @@ -266,8 +266,7 @@ source <(jj support completion) # --bash is the default ```shell script autoload -U compinit compinit -source <(jj support completion --zsh | sed '$d') # remove the last line -compdef _jj jj +source <(jj support completion --zsh) ``` ### Fish diff --git a/tests/test_alias.rs b/tests/test_alias.rs index 55a170090..0672b7069 100644 --- a/tests/test_alias.rs +++ b/tests/test_alias.rs @@ -67,11 +67,11 @@ fn test_alias_bad_name() { let stderr = test_env.jj_cmd_cli_error(&repo_path, &["foo."]); insta::assert_snapshot!(stderr, @r###" - error: The subcommand 'foo.' wasn't recognized + error: unrecognized subcommand 'foo.' Usage: jj [OPTIONS] - For more information try '--help' + For more information, try '--help'. "###); } @@ -84,11 +84,11 @@ fn test_alias_calls_unknown_command() { test_env.add_config(r#"aliases.foo = ["nonexistent"]"#); let stderr = test_env.jj_cmd_cli_error(&repo_path, &["foo"]); insta::assert_snapshot!(stderr, @r###" - error: The subcommand 'nonexistent' wasn't recognized + error: unrecognized subcommand 'nonexistent' Usage: jj [OPTIONS] - For more information try '--help' + For more information, try '--help'. "###); } @@ -101,13 +101,13 @@ fn test_alias_calls_command_with_invalid_option() { test_env.add_config(r#"aliases.foo = ["log", "--nonexistent"]"#); let stderr = test_env.jj_cmd_cli_error(&repo_path, &["foo"]); insta::assert_snapshot!(stderr, @r###" - error: Found argument '--nonexistent' which wasn't expected, or isn't valid in this context + error: unexpected argument '--nonexistent' found - If you tried to supply '--nonexistent' as a value rather than a flag, use '-- --nonexistent' + note: to pass '--nonexistent' as a value, use '-- --nonexistent' Usage: jj log [OPTIONS] [PATHS]... - For more information try '--help' + For more information, try '--help'. "###); } diff --git a/tests/test_branch_command.rs b/tests/test_branch_command.rs index df96a1ee2..067b28f31 100644 --- a/tests/test_branch_command.rs +++ b/tests/test_branch_command.rs @@ -53,9 +53,9 @@ fn test_branch_empty_name() { let stderr = test_env.jj_cmd_cli_error(&repo_path, &["branch", "create", ""]); insta::assert_snapshot!(stderr, @r###" - error: The argument '...' requires a value but none was supplied + error: a value is required for '...' but none was supplied - For more information try '--help' + For more information, try '--help'. "###); } #[test] diff --git a/tests/test_config_command.rs b/tests/test_config_command.rs index 9499a5254..78e7a38b5 100644 --- a/tests/test_config_command.rs +++ b/tests/test_config_command.rs @@ -270,14 +270,14 @@ fn test_config_set_missing_opts() { let test_env = TestEnvironment::default(); let stderr = test_env.jj_cmd_cli_error(test_env.env_root(), &["config", "set"]); insta::assert_snapshot!(stderr, @r###" - error: The following required arguments were not provided: + error: the following required arguments were not provided: <--user|--repo> Usage: jj config set <--user|--repo> - For more information try '--help' + For more information, try '--help'. "###); } @@ -387,12 +387,12 @@ fn test_config_edit_missing_opt() { let test_env = TestEnvironment::default(); let stderr = test_env.jj_cmd_cli_error(test_env.env_root(), &["config", "edit"]); insta::assert_snapshot!(stderr, @r###" - error: The following required arguments were not provided: + error: the following required arguments were not provided: <--user|--repo> Usage: jj config edit <--user|--repo> - For more information try '--help' + For more information, try '--help'. "###); } diff --git a/tests/test_diff_command.rs b/tests/test_diff_command.rs index 408b0ee9d..23d6540ce 100644 --- a/tests/test_diff_command.rs +++ b/tests/test_diff_command.rs @@ -186,20 +186,20 @@ fn test_diff_bad_args() { let stderr = test_env.jj_cmd_cli_error(&repo_path, &["diff", "-s", "--types"]); insta::assert_snapshot!(stderr, @r###" - error: The argument '--summary' cannot be used with '--types' + error: the argument '--summary' cannot be used with '--types' Usage: jj diff --summary [PATHS]... - For more information try '--help' + For more information, try '--help'. "###); let stderr = test_env.jj_cmd_cli_error(&repo_path, &["diff", "--color-words", "--git"]); insta::assert_snapshot!(stderr, @r###" - error: The argument '--color-words' cannot be used with '--git' + error: the argument '--color-words' cannot be used with '--git' Usage: jj diff --color-words [PATHS]... - For more information try '--help' + For more information, try '--help'. "###); } diff --git a/tests/test_edit_command.rs b/tests/test_edit_command.rs index 6c5e837f7..2c38142fc 100644 --- a/tests/test_edit_command.rs +++ b/tests/test_edit_command.rs @@ -31,12 +31,12 @@ fn test_edit() { // Errors out without argument let stderr = test_env.jj_cmd_cli_error(&repo_path, &["edit"]); insta::assert_snapshot!(stderr, @r###" - error: The following required arguments were not provided: + error: the following required arguments were not provided: Usage: jj edit - For more information try '--help' + For more information, try '--help'. "###); // Makes the specified commit the working-copy commit diff --git a/tests/test_global_opts.rs b/tests/test_global_opts.rs index d51d7f1a9..f96b26604 100644 --- a/tests/test_global_opts.rs +++ b/tests/test_global_opts.rs @@ -373,7 +373,7 @@ fn test_help() { -r, --revision The revision to touch up. Defaults to @ if --to/--from are not specified --from Show changes from this revision. Defaults to @ if --to is specified --to Edit changes in this revision. Defaults to @ if --from is specified - -h, --help Print help information (use `--help` for more detail) + -h, --help Print help (see more with '--help') Global Options: -R, --repository Path to repository to operate on diff --git a/tests/test_log_command.rs b/tests/test_log_command.rs index 7df8c8a5b..6a81cfb89 100644 --- a/tests/test_log_command.rs +++ b/tests/test_log_command.rs @@ -24,9 +24,9 @@ fn test_log_with_empty_revision() { let stderr = test_env.jj_cmd_cli_error(&repo_path, &["log", "-r="]); insta::assert_snapshot!(stderr, @r###" - error: The argument '--revisions ' requires a value but none was supplied + error: a value is required for '--revisions ' but none was supplied - For more information try '--help' + For more information, try '--help'. "###); } @@ -179,11 +179,11 @@ fn test_log_with_or_without_diff() { ], ); insta::assert_snapshot!(stderr, @r###" - error: The argument '--git' cannot be used with '--color-words' + error: the argument '--git' cannot be used with '--color-words' Usage: jj log --template