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.
This commit is contained in:
Martin von Zweigbergk 2023-03-17 16:14:20 -07:00 committed by Martin von Zweigbergk
parent 2495c8f27e
commit 8f1dc49039
13 changed files with 49 additions and 50 deletions

22
Cargo.lock generated
View file

@ -230,9 +230,9 @@ dependencies = [
[[package]] [[package]]
name = "clap" name = "clap"
version = "4.0.32" version = "4.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7db700bc935f9e43e88d00b0850dae18a63773cfbec6d8e070fccf7fef89a39" checksum = "9a9d6ada83c1edcce028902ea27dd929069c70df4c7600b131b4d9a1ad2879cc"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"clap_derive", "clap_derive",
@ -245,18 +245,18 @@ dependencies = [
[[package]] [[package]]
name = "clap_complete" name = "clap_complete"
version = "4.0.7" version = "4.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10861370d2ba66b0f5989f83ebf35db6421713fd92351790e7fdd6c36774c56b" checksum = "37686beaba5ac9f3ab01ee3172f792fc6ffdd685bfb9e63cfef02c0571a4e8e1"
dependencies = [ dependencies = [
"clap 4.0.32", "clap 4.1.9",
] ]
[[package]] [[package]]
name = "clap_derive" name = "clap_derive"
version = "4.0.21" version = "4.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0177313f9f02afc995627906bbd8967e2be069f5261954222dac78290c2b9014" checksum = "fddf67631444a3a3e3e5ac51c36a5e01335302de677bd78759eaa90ab1f46644"
dependencies = [ dependencies = [
"heck", "heck",
"proc-macro-error", "proc-macro-error",
@ -285,11 +285,11 @@ dependencies = [
[[package]] [[package]]
name = "clap_mangen" name = "clap_mangen"
version = "0.2.6" version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "904eb24d05ad587557e0f484ddce5c737c30cf81372badb16d13e41c4b8340b1" checksum = "4237e29de9c6949982ba87d51709204504fb8ed2fd38232fcb1e5bf7d4ba48c8"
dependencies = [ dependencies = [
"clap 4.0.32", "clap 4.1.9",
"roff", "roff",
] ]
@ -799,7 +799,7 @@ dependencies = [
"assert_cmd", "assert_cmd",
"assert_matches", "assert_matches",
"chrono", "chrono",
"clap 4.0.32", "clap 4.1.9",
"clap_complete", "clap_complete",
"clap_mangen", "clap_mangen",
"config", "config",

View file

@ -35,9 +35,9 @@ members = ["lib", "lib/testutils", "lib/gen-protos"]
[dependencies] [dependencies]
chrono = { version = "0.4.24", default-features = false, features = ["std", "clock"] } chrono = { version = "0.4.24", default-features = false, features = ["std", "clock"] }
clap = { version = "4.0.32", features = ["derive", "deprecated"] } clap = { version = "4.1.9", features = ["derive", "deprecated"] }
clap_complete = "4.0.7" clap_complete = "4.1.5"
clap_mangen = "0.2.6" clap_mangen = "0.2.10"
config = { version = "0.13.3", default-features = false, features = ["toml"] } config = { version = "0.13.3", default-features = false, features = ["toml"] }
crossterm = { version = "0.26", default-features = false } crossterm = { version = "0.26", default-features = false }
dirs = "4.0.0" dirs = "4.0.0"

View file

@ -266,8 +266,7 @@ source <(jj support completion) # --bash is the default
```shell script ```shell script
autoload -U compinit autoload -U compinit
compinit compinit
source <(jj support completion --zsh | sed '$d') # remove the last line source <(jj support completion --zsh)
compdef _jj jj
``` ```
### Fish ### Fish

View file

@ -67,11 +67,11 @@ fn test_alias_bad_name() {
let stderr = test_env.jj_cmd_cli_error(&repo_path, &["foo."]); let stderr = test_env.jj_cmd_cli_error(&repo_path, &["foo."]);
insta::assert_snapshot!(stderr, @r###" insta::assert_snapshot!(stderr, @r###"
error: The subcommand 'foo.' wasn't recognized error: unrecognized subcommand 'foo.'
Usage: jj [OPTIONS] <COMMAND> Usage: jj [OPTIONS] <COMMAND>
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"]"#); test_env.add_config(r#"aliases.foo = ["nonexistent"]"#);
let stderr = test_env.jj_cmd_cli_error(&repo_path, &["foo"]); let stderr = test_env.jj_cmd_cli_error(&repo_path, &["foo"]);
insta::assert_snapshot!(stderr, @r###" insta::assert_snapshot!(stderr, @r###"
error: The subcommand 'nonexistent' wasn't recognized error: unrecognized subcommand 'nonexistent'
Usage: jj [OPTIONS] <COMMAND> Usage: jj [OPTIONS] <COMMAND>
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"]"#); test_env.add_config(r#"aliases.foo = ["log", "--nonexistent"]"#);
let stderr = test_env.jj_cmd_cli_error(&repo_path, &["foo"]); let stderr = test_env.jj_cmd_cli_error(&repo_path, &["foo"]);
insta::assert_snapshot!(stderr, @r###" 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]... Usage: jj log [OPTIONS] [PATHS]...
For more information try '--help' For more information, try '--help'.
"###); "###);
} }

View file

@ -53,9 +53,9 @@ fn test_branch_empty_name() {
let stderr = test_env.jj_cmd_cli_error(&repo_path, &["branch", "create", ""]); let stderr = test_env.jj_cmd_cli_error(&repo_path, &["branch", "create", ""]);
insta::assert_snapshot!(stderr, @r###" insta::assert_snapshot!(stderr, @r###"
error: The argument '<NAMES>...' requires a value but none was supplied error: a value is required for '<NAMES>...' but none was supplied
For more information try '--help' For more information, try '--help'.
"###); "###);
} }
#[test] #[test]

View file

@ -270,14 +270,14 @@ fn test_config_set_missing_opts() {
let test_env = TestEnvironment::default(); let test_env = TestEnvironment::default();
let stderr = test_env.jj_cmd_cli_error(test_env.env_root(), &["config", "set"]); let stderr = test_env.jj_cmd_cli_error(test_env.env_root(), &["config", "set"]);
insta::assert_snapshot!(stderr, @r###" insta::assert_snapshot!(stderr, @r###"
error: The following required arguments were not provided: error: the following required arguments were not provided:
<--user|--repo> <--user|--repo>
<NAME> <NAME>
<VALUE> <VALUE>
Usage: jj config set <--user|--repo> <NAME> <VALUE> Usage: jj config set <--user|--repo> <NAME> <VALUE>
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 test_env = TestEnvironment::default();
let stderr = test_env.jj_cmd_cli_error(test_env.env_root(), &["config", "edit"]); let stderr = test_env.jj_cmd_cli_error(test_env.env_root(), &["config", "edit"]);
insta::assert_snapshot!(stderr, @r###" insta::assert_snapshot!(stderr, @r###"
error: The following required arguments were not provided: error: the following required arguments were not provided:
<--user|--repo> <--user|--repo>
Usage: jj config edit <--user|--repo> Usage: jj config edit <--user|--repo>
For more information try '--help' For more information, try '--help'.
"###); "###);
} }

View file

@ -186,20 +186,20 @@ fn test_diff_bad_args() {
let stderr = test_env.jj_cmd_cli_error(&repo_path, &["diff", "-s", "--types"]); let stderr = test_env.jj_cmd_cli_error(&repo_path, &["diff", "-s", "--types"]);
insta::assert_snapshot!(stderr, @r###" 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]... 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"]); let stderr = test_env.jj_cmd_cli_error(&repo_path, &["diff", "--color-words", "--git"]);
insta::assert_snapshot!(stderr, @r###" 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]... Usage: jj diff --color-words [PATHS]...
For more information try '--help' For more information, try '--help'.
"###); "###);
} }

View file

@ -31,12 +31,12 @@ fn test_edit() {
// Errors out without argument // Errors out without argument
let stderr = test_env.jj_cmd_cli_error(&repo_path, &["edit"]); let stderr = test_env.jj_cmd_cli_error(&repo_path, &["edit"]);
insta::assert_snapshot!(stderr, @r###" insta::assert_snapshot!(stderr, @r###"
error: The following required arguments were not provided: error: the following required arguments were not provided:
<REVISION> <REVISION>
Usage: jj edit <REVISION> Usage: jj edit <REVISION>
For more information try '--help' For more information, try '--help'.
"###); "###);
// Makes the specified commit the working-copy commit // Makes the specified commit the working-copy commit

View file

@ -373,7 +373,7 @@ fn test_help() {
-r, --revision <REVISION> The revision to touch up. Defaults to @ if --to/--from are not specified -r, --revision <REVISION> The revision to touch up. Defaults to @ if --to/--from are not specified
--from <FROM> Show changes from this revision. Defaults to @ if --to is specified --from <FROM> Show changes from this revision. Defaults to @ if --to is specified
--to <TO> Edit changes in this revision. Defaults to @ if --from is specified --to <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: Global Options:
-R, --repository <REPOSITORY> Path to repository to operate on -R, --repository <REPOSITORY> Path to repository to operate on

View file

@ -24,9 +24,9 @@ fn test_log_with_empty_revision() {
let stderr = test_env.jj_cmd_cli_error(&repo_path, &["log", "-r="]); let stderr = test_env.jj_cmd_cli_error(&repo_path, &["log", "-r="]);
insta::assert_snapshot!(stderr, @r###" insta::assert_snapshot!(stderr, @r###"
error: The argument '--revisions <REVISIONS>' requires a value but none was supplied error: a value is required for '--revisions <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###" 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 <TEMPLATE> --no-graph --patch --git [PATHS]... Usage: jj log --template <TEMPLATE> --no-graph --patch --git [PATHS]...
For more information try '--help' For more information, try '--help'.
"###); "###);
// `-s` with or without graph // `-s` with or without graph

View file

@ -70,12 +70,12 @@ fn test_move() {
// Errors out without arguments // Errors out without arguments
let stderr = test_env.jj_cmd_cli_error(&repo_path, &["move"]); let stderr = test_env.jj_cmd_cli_error(&repo_path, &["move"]);
insta::assert_snapshot!(stderr, @r###" insta::assert_snapshot!(stderr, @r###"
error: The following required arguments were not provided: error: the following required arguments were not provided:
<--from <FROM>|--to <TO>> <--from <FROM>|--to <TO>>
Usage: jj move <--from <FROM>|--to <TO>> [PATHS]... Usage: jj move <--from <FROM>|--to <TO>> [PATHS]...
For more information try '--help' For more information, try '--help'.
"###); "###);
// Errors out if source and destination are the same // Errors out if source and destination are the same
let stderr = test_env.jj_cmd_failure(&repo_path, &["move", "--to", "@"]); let stderr = test_env.jj_cmd_failure(&repo_path, &["move", "--to", "@"]);

View file

@ -42,34 +42,34 @@ fn test_rebase_invalid() {
// Missing destination // Missing destination
let stderr = test_env.jj_cmd_cli_error(&repo_path, &["rebase"]); let stderr = test_env.jj_cmd_cli_error(&repo_path, &["rebase"]);
insta::assert_snapshot!(stderr, @r###" insta::assert_snapshot!(stderr, @r###"
error: The following required arguments were not provided: error: the following required arguments were not provided:
--destination <DESTINATION> --destination <DESTINATION>
Usage: jj rebase --destination <DESTINATION> Usage: jj rebase --destination <DESTINATION>
For more information try '--help' For more information, try '--help'.
"###); "###);
// Both -r and -s // Both -r and -s
let stderr = let stderr =
test_env.jj_cmd_cli_error(&repo_path, &["rebase", "-r", "a", "-s", "a", "-d", "b"]); test_env.jj_cmd_cli_error(&repo_path, &["rebase", "-r", "a", "-s", "a", "-d", "b"]);
insta::assert_snapshot!(stderr, @r###" insta::assert_snapshot!(stderr, @r###"
error: The argument '--revision <REVISION>' cannot be used with '--source <SOURCE>' error: the argument '--revision <REVISION>' cannot be used with '--source <SOURCE>'
Usage: jj rebase --destination <DESTINATION> --revision <REVISION> Usage: jj rebase --destination <DESTINATION> --revision <REVISION>
For more information try '--help' For more information, try '--help'.
"###); "###);
// Both -b and -s // Both -b and -s
let stderr = let stderr =
test_env.jj_cmd_cli_error(&repo_path, &["rebase", "-b", "a", "-s", "a", "-d", "b"]); test_env.jj_cmd_cli_error(&repo_path, &["rebase", "-b", "a", "-s", "a", "-d", "b"]);
insta::assert_snapshot!(stderr, @r###" insta::assert_snapshot!(stderr, @r###"
error: The argument '--branch <BRANCH>' cannot be used with '--source <SOURCE>' error: the argument '--branch <BRANCH>' cannot be used with '--source <SOURCE>'
Usage: jj rebase --destination <DESTINATION> --branch <BRANCH> Usage: jj rebase --destination <DESTINATION> --branch <BRANCH>
For more information try '--help' For more information, try '--help'.
"###); "###);
// Rebase onto descendant with -r // Rebase onto descendant with -r

View file

@ -48,12 +48,12 @@ fn test_untrack() {
// Errors out when no path is specified // Errors out when no path is specified
let stderr = test_env.jj_cmd_cli_error(&repo_path, &["untrack"]); let stderr = test_env.jj_cmd_cli_error(&repo_path, &["untrack"]);
insta::assert_snapshot!(stderr, @r###" insta::assert_snapshot!(stderr, @r###"
error: The following required arguments were not provided: error: the following required arguments were not provided:
<PATHS>... <PATHS>...
Usage: jj untrack <PATHS>... Usage: jj untrack <PATHS>...
For more information try '--help' For more information, try '--help'.
"###); "###);
// Errors out when a specified file is not ignored // Errors out when a specified file is not ignored
let stderr = test_env.jj_cmd_failure(&repo_path, &["untrack", "file1", "file1.bak"]); let stderr = test_env.jj_cmd_failure(&repo_path, &["untrack", "file1", "file1.bak"]);