Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: Remove deprecated ArgActions #3977

Merged
merged 6 commits into from Jul 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- `ErrorKind::EmptyValue` replaced with `ErrorKind::InvalidValue`
- `ErrorKind::UnrecognizedSubcommand` replaced with `ErrorKind::InvalidSubcommand` (#3676)
- `arg!` now sets `ArgAction::SetTrue`, `ArgAction::Count`, `ArgAction::Set`, or `ArgAction::Append` as appropriate (#3795)
- Default actions are now `Set` and `SetTrue`
- *(help)* Make `DeriveDisplayOrder` the default and removed the setting. To sort help, set `next_display_order(None)` (#2808)
- *(help)* Subcommand display order respects `Command::next_display_order` instead of `DeriveDisplayOrder` and using its own initial display order value (#2808)
- *(env)* Parse `--help` and `--version` like any `ArgAction::SetTrue` flag (#3776)
Expand Down
16 changes: 8 additions & 8 deletions clap_complete/tests/snapshots/aliases.zsh
Expand Up @@ -15,18 +15,18 @@ _my-app() {

local context curcontext="$curcontext" state line
_arguments "${_arguments_options[@]}" /
'-o+[cmd option]: : ' /
'-O+[cmd option]: : ' /
'--option=[cmd option]: : ' /
'--opt=[cmd option]: : ' /
'*-o+[cmd option]: : ' /
'*-O+[cmd option]: : ' /
'*--option=[cmd option]: : ' /
'*--opt=[cmd option]: : ' /
'-h[Print help information]' /
'--help[Print help information]' /
'-V[Print version information]' /
'--version[Print version information]' /
'-f[cmd flag]' /
'-F[cmd flag]' /
'--flag[cmd flag]' /
'--flg[cmd flag]' /
'*-f[cmd flag]' /
'*-F[cmd flag]' /
'*--flag[cmd flag]' /
'*--flg[cmd flag]' /
'::positional:' /
&& ret=0
}
Expand Down
8 changes: 4 additions & 4 deletions clap_complete/tests/snapshots/basic.zsh
Expand Up @@ -17,8 +17,8 @@ _my-app() {
_arguments "${_arguments_options[@]}" /
'-h[Print help information]' /
'--help[Print help information]' /
'-c[]' /
'(-c)-v[]' /
'*-c[]' /
'(-c)*-v[]' /
":: :_my-app_commands" /
"*::: :->my-app" /
&& ret=0
Expand All @@ -33,12 +33,12 @@ _arguments "${_arguments_options[@]}" /
'*-d[]' /
'-h[Print help information]' /
'--help[Print help information]' /
'-c[]' /
'*-c[]' /
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" /
'-c[]' /
'*-c[]' /
'*::subcommand -- The subcommand whose help message to display:' /
&& ret=0
;;
Expand Down
2 changes: 1 addition & 1 deletion clap_complete/tests/snapshots/feature_sample.zsh
Expand Up @@ -36,7 +36,7 @@ _my-app() {
case $line[3] in
(test)
_arguments "${_arguments_options[@]}" /
'--case=[the case to test]: : ' /
'*--case=[the case to test]: : ' /
'-h[Print help information]' /
'--help[Print help information]' /
'-V[Print version information]' /
Expand Down
12 changes: 6 additions & 6 deletions clap_complete/tests/snapshots/quoting.zsh
Expand Up @@ -19,12 +19,12 @@ _my-app() {
'--help[Print help information]' /
'-V[Print version information]' /
'--version[Print version information]' /
'--single-quotes[Can be '/''always'/'', '/''auto'/'', or '/''never'/'']' /
'--double-quotes[Can be "always", "auto", or "never"]' /
'--backticks[For more information see `echo test`]' /
'--backslash[Avoid '/''//n'/'']' /
'--brackets[List packages /[filter/]]' /
'--expansions[Execute the shell command with $SHELL]' /
'*--single-quotes[Can be '/''always'/'', '/''auto'/'', or '/''never'/'']' /
'*--double-quotes[Can be "always", "auto", or "never"]' /
'*--backticks[For more information see `echo test`]' /
'*--backslash[Avoid '/''//n'/'']' /
'*--brackets[List packages /[filter/]]' /
'*--expansions[Execute the shell command with $SHELL]' /
":: :_my-app_commands" /
"*::: :->my-app" /
&& ret=0
Expand Down
4 changes: 2 additions & 2 deletions clap_complete/tests/snapshots/special_commands.zsh
Expand Up @@ -36,7 +36,7 @@ _my-app() {
case $line[3] in
(test)
_arguments "${_arguments_options[@]}" /
'--case=[the case to test]: : ' /
'*--case=[the case to test]: : ' /
'-h[Print help information]' /
'--help[Print help information]' /
'-V[Print version information]' /
Expand All @@ -45,7 +45,7 @@ _arguments "${_arguments_options[@]}" /
;;
(some_cmd)
_arguments "${_arguments_options[@]}" /
'--config=[the other case to test]: : ' /
'*--config=[the other case to test]: : ' /
'-h[Print help information]' /
'--help[Print help information]' /
'-V[Print version information]' /
Expand Down
4 changes: 2 additions & 2 deletions clap_complete/tests/snapshots/sub_subcommands.zsh
Expand Up @@ -36,7 +36,7 @@ _my-app() {
case $line[3] in
(test)
_arguments "${_arguments_options[@]}" /
'--case=[the case to test]: : ' /
'*--case=[the case to test]: : ' /
'-h[Print help information]' /
'--help[Print help information]' /
'-V[Print version information]' /
Expand All @@ -61,7 +61,7 @@ _arguments "${_arguments_options[@]}" /
case $line[1] in
(sub_cmd)
_arguments "${_arguments_options[@]}" /
'--config=[the other case to test]: :(Lest quotes aren't escaped.)' /
'*--config=[the other case to test]: :(Lest quotes aren't escaped.)' /
'-h[Print help information]' /
'--help[Print help information]' /
'-V[Print version information]' /
Expand Down
40 changes: 20 additions & 20 deletions clap_complete/tests/snapshots/value_hint.zsh
Expand Up @@ -15,26 +15,26 @@ _my-app() {

local context curcontext="$curcontext" state line
_arguments "${_arguments_options[@]}" /
'--choice=[]: :(bash fish zsh)' /
'--unknown=[]: : ' /
'--other=[]: :( )' /
'-p+[]: :_files' /
'--path=[]: :_files' /
'-f+[]: :_files' /
'--file=[]: :_files' /
'-d+[]: :_files -/' /
'--dir=[]: :_files -/' /
'-e+[]: :_absolute_command_paths' /
'--exe=[]: :_absolute_command_paths' /
'--cmd-name=[]: :_command_names -e' /
'-c+[]: :_cmdstring' /
'--cmd=[]: :_cmdstring' /
'-u+[]: :_users' /
'--user=[]: :_users' /
'-h+[]: :_hosts' /
'--host=[]: :_hosts' /
'--url=[]: :_urls' /
'--email=[]: :_email_addresses' /
'*--choice=[]: :(bash fish zsh)' /
'*--unknown=[]: : ' /
'*--other=[]: :( )' /
'*-p+[]: :_files' /
'*--path=[]: :_files' /
'*-f+[]: :_files' /
'*--file=[]: :_files' /
'*-d+[]: :_files -/' /
'*--dir=[]: :_files -/' /
'*-e+[]: :_absolute_command_paths' /
'*--exe=[]: :_absolute_command_paths' /
'*--cmd-name=[]: :_command_names -e' /
'*-c+[]: :_cmdstring' /
'*--cmd=[]: :_cmdstring' /
'*-u+[]: :_users' /
'*--user=[]: :_users' /
'*-h+[]: :_hosts' /
'*--host=[]: :_hosts' /
'*--url=[]: :_urls' /
'*--email=[]: :_email_addresses' /
'--help[Print help information]' /
'*::command_with_args:_cmdambivalent' /
&& ret=0
Expand Down
26 changes: 0 additions & 26 deletions clap_complete_fig/src/fig.rs
Expand Up @@ -216,19 +216,6 @@ fn gen_options(cmd: &Command, indent: usize) -> String {
buffer.push_str(&format!("{:indent$}],\n", "", indent = indent + 4));
}

#[allow(deprecated)]
if matches!(
option.get_action(),
ArgAction::StoreValue | ArgAction::IncOccurrence
) && option.is_multiple_occurrences_set()
{
buffer.push_str(&format!(
"{:indent$}isRepeatable: true,\n",
"",
indent = indent + 4
));
}

if let ArgAction::Set | ArgAction::Append | ArgAction::Count = option.get_action() {
buffer.push_str(&format!(
"{:indent$}isRepeatable: true,\n",
Expand Down Expand Up @@ -316,19 +303,6 @@ fn gen_options(cmd: &Command, indent: usize) -> String {
buffer.push_str(&format!("{:indent$}],\n", "", indent = indent + 4));
}

#[allow(deprecated)]
if matches!(
flag.get_action(),
ArgAction::StoreValue | ArgAction::IncOccurrence
) && flag.is_multiple_occurrences_set()
{
buffer.push_str(&format!(
"{:indent$}isRepeatable: true,\n",
"",
indent = indent + 4
));
}

if let ArgAction::Set | ArgAction::Append | ArgAction::Count = flag.get_action() {
buffer.push_str(&format!(
"{:indent$}isRepeatable: true,\n",
Expand Down
1 change: 1 addition & 0 deletions clap_complete_fig/tests/snapshots/aliases.fig.js
Expand Up @@ -5,6 +5,7 @@ const completion: Fig.Spec = {
{
name: ["-o", "-O", "--option", "--opt"],
description: "cmd option",
isRepeatable: true,
args: {
name: "option",
isOptional: true,
Expand Down
1 change: 1 addition & 0 deletions clap_complete_fig/tests/snapshots/feature_sample.fig.js
Expand Up @@ -9,6 +9,7 @@ const completion: Fig.Spec = {
{
name: "--case",
description: "the case to test",
isRepeatable: true,
args: {
name: "case",
isOptional: true,
Expand Down
2 changes: 2 additions & 0 deletions clap_complete_fig/tests/snapshots/special_commands.fig.js
Expand Up @@ -9,6 +9,7 @@ const completion: Fig.Spec = {
{
name: "--case",
description: "the case to test",
isRepeatable: true,
args: {
name: "case",
isOptional: true,
Expand All @@ -32,6 +33,7 @@ const completion: Fig.Spec = {
name: "--config",
description: "the other case to test",
hidden: true,
isRepeatable: true,
requiresEquals: true,
args: {
name: "config",
Expand Down
2 changes: 2 additions & 0 deletions clap_complete_fig/tests/snapshots/sub_subcommands.fig.js
Expand Up @@ -9,6 +9,7 @@ const completion: Fig.Spec = {
{
name: "--case",
description: "the case to test",
isRepeatable: true,
args: {
name: "case",
isOptional: true,
Expand All @@ -35,6 +36,7 @@ const completion: Fig.Spec = {
{
name: "--config",
description: "the other case to test",
isRepeatable: true,
args: {
name: "config",
isOptional: true,
Expand Down
13 changes: 13 additions & 0 deletions clap_complete_fig/tests/snapshots/value_hint.fig.js
Expand Up @@ -4,6 +4,7 @@ const completion: Fig.Spec = {
options: [
{
name: "--choice",
isRepeatable: true,
args: {
name: "choice",
isOptional: true,
Expand All @@ -16,20 +17,23 @@ const completion: Fig.Spec = {
},
{
name: "--unknown",
isRepeatable: true,
args: {
name: "unknown",
isOptional: true,
},
},
{
name: "--other",
isRepeatable: true,
args: {
name: "other",
isOptional: true,
},
},
{
name: ["-p", "--path"],
isRepeatable: true,
args: {
name: "path",
isOptional: true,
Expand All @@ -38,6 +42,7 @@ const completion: Fig.Spec = {
},
{
name: ["-f", "--file"],
isRepeatable: true,
args: {
name: "file",
isOptional: true,
Expand All @@ -46,6 +51,7 @@ const completion: Fig.Spec = {
},
{
name: ["-d", "--dir"],
isRepeatable: true,
args: {
name: "dir",
isOptional: true,
Expand All @@ -54,6 +60,7 @@ const completion: Fig.Spec = {
},
{
name: ["-e", "--exe"],
isRepeatable: true,
args: {
name: "exe",
isOptional: true,
Expand All @@ -62,6 +69,7 @@ const completion: Fig.Spec = {
},
{
name: "--cmd-name",
isRepeatable: true,
args: {
name: "cmd_name",
isOptional: true,
Expand All @@ -70,6 +78,7 @@ const completion: Fig.Spec = {
},
{
name: ["-c", "--cmd"],
isRepeatable: true,
args: {
name: "cmd",
isOptional: true,
Expand All @@ -78,27 +87,31 @@ const completion: Fig.Spec = {
},
{
name: ["-u", "--user"],
isRepeatable: true,
args: {
name: "user",
isOptional: true,
},
},
{
name: ["-h", "--host"],
isRepeatable: true,
args: {
name: "host",
isOptional: true,
},
},
{
name: "--url",
isRepeatable: true,
args: {
name: "url",
isOptional: true,
},
},
{
name: "--email",
isRepeatable: true,
args: {
name: "email",
isOptional: true,
Expand Down
2 changes: 1 addition & 1 deletion clap_mangen/tests/snapshots/aliases.bash.roff
Expand Up @@ -15,7 +15,7 @@ Print help information
/fB/-V/fR, /fB/-/-version/fR
Print version information
.TP
/fB/-f/fR, /fB/-/-flag/fR
/fB/-f/fR, /fB/-/-flag/fR [default: false]
cmd flag
.TP
/fB/-o/fR, /fB/-/-option/fR
Expand Down
4 changes: 2 additions & 2 deletions clap_mangen/tests/snapshots/basic.bash.roff
Expand Up @@ -11,10 +11,10 @@ my/-app
/fB/-h/fR, /fB/-/-help/fR
Print help information
.TP
/fB/-c/fR
/fB/-c/fR [default: false]

.TP
/fB/-v/fR
/fB/-v/fR [default: false]

.SH SUBCOMMANDS
.TP
Expand Down
2 changes: 1 addition & 1 deletion clap_mangen/tests/snapshots/feature_sample.bash.roff
Expand Up @@ -15,7 +15,7 @@ Print help information
/fB/-V/fR, /fB/-/-version/fR
Print version information
.TP
/fB/-c/fR, /fB/-/-config/fR
/fB/-c/fR, /fB/-/-config/fR [default: false]
some config file
.TP
[/fIfile/fR]
Expand Down