Skip to content

Commit

Permalink
cargo: upgrade to clap 4.1
Browse files Browse the repository at this point in the history
This includes some changes to error messages. Also, the Zsh shell
completion script is now simpler to source.

Fixes #1393.
  • Loading branch information
martinvonz committed Mar 18, 2023
1 parent 2495c8f commit 8f1dc49
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 50 deletions.
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions tests/test_alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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] <COMMAND>
For more information try '--help'
For more information, try '--help'.
"###);
}

Expand All @@ -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] <COMMAND>
For more information try '--help'
For more information, try '--help'.
"###);
}

Expand All @@ -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'.
"###);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/test_branch_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<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]
Expand Down
8 changes: 4 additions & 4 deletions tests/test_config_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
<NAME>
<VALUE>
Usage: jj config set <--user|--repo> <NAME> <VALUE>
For more information try '--help'
For more information, try '--help'.
"###);
}

Expand Down Expand Up @@ -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'.
"###);
}

Expand Down
8 changes: 4 additions & 4 deletions tests/test_diff_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
"###);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/test_edit_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
<REVISION>
Usage: jj edit <REVISION>
For more information try '--help'
For more information, try '--help'.
"###);

// Makes the specified commit the working-copy commit
Expand Down
2 changes: 1 addition & 1 deletion tests/test_global_opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ fn test_help() {
-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
--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:
-R, --repository <REPOSITORY> Path to repository to operate on
Expand Down
8 changes: 4 additions & 4 deletions tests/test_log_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <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'.
"###);
}

Expand Down Expand Up @@ -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 <TEMPLATE> --no-graph --patch --git [PATHS]...
For more information try '--help'
For more information, try '--help'.
"###);

// `-s` with or without graph
Expand Down
4 changes: 2 additions & 2 deletions tests/test_move_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ fn test_move() {
// Errors out without arguments
let stderr = test_env.jj_cmd_cli_error(&repo_path, &["move"]);
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>>
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
let stderr = test_env.jj_cmd_failure(&repo_path, &["move", "--to", "@"]);
Expand Down
12 changes: 6 additions & 6 deletions tests/test_rebase_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,34 +42,34 @@ fn test_rebase_invalid() {
// Missing destination
let stderr = test_env.jj_cmd_cli_error(&repo_path, &["rebase"]);
insta::assert_snapshot!(stderr, @r###"
error: The following required arguments were not provided:
error: the following required arguments were not provided:
--destination <DESTINATION>
Usage: jj rebase --destination <DESTINATION>
For more information try '--help'
For more information, try '--help'.
"###);

// Both -r and -s
let stderr =
test_env.jj_cmd_cli_error(&repo_path, &["rebase", "-r", "a", "-s", "a", "-d", "b"]);
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>
For more information try '--help'
For more information, try '--help'.
"###);

// Both -b and -s
let stderr =
test_env.jj_cmd_cli_error(&repo_path, &["rebase", "-b", "a", "-s", "a", "-d", "b"]);
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>
For more information try '--help'
For more information, try '--help'.
"###);

// Rebase onto descendant with -r
Expand Down
4 changes: 2 additions & 2 deletions tests/test_untrack_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ fn test_untrack() {
// Errors out when no path is specified
let stderr = test_env.jj_cmd_cli_error(&repo_path, &["untrack"]);
insta::assert_snapshot!(stderr, @r###"
error: The following required arguments were not provided:
error: the following required arguments were not provided:
<PATHS>...
Usage: jj untrack <PATHS>...
For more information try '--help'
For more information, try '--help'.
"###);
// Errors out when a specified file is not ignored
let stderr = test_env.jj_cmd_failure(&repo_path, &["untrack", "file1", "file1.bak"]);
Expand Down

0 comments on commit 8f1dc49

Please sign in to comment.