Skip to content

Commit

Permalink
test(complete): Show newline issue
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Feb 16, 2024
1 parent 8a7a13a commit fba7c85
Show file tree
Hide file tree
Showing 18 changed files with 69 additions and 35 deletions.
6 changes: 4 additions & 2 deletions clap_complete/tests/snapshots/basic.elvish
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ set edit:completion:arg-completer[my-app] = {|@words|
cand -v 'v'
cand -h 'Print help'
cand --help 'Print help'
cand test 'Subcommand'
cand test 'Subcommand
with a second line'
cand help 'Print this message or the help of the given subcommand(s)'
}
&'my-app;test'= {
Expand All @@ -32,7 +33,8 @@ set edit:completion:arg-completer[my-app] = {|@words|
cand --help 'Print help'
}
&'my-app;help'= {
cand test 'Subcommand'
cand test 'Subcommand
with a second line'
cand help 'Print this message or the help of the given subcommand(s)'
}
&'my-app;help;test'= {
Expand Down
6 changes: 4 additions & 2 deletions clap_complete/tests/snapshots/basic.fish
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
complete -c my-app -n "__fish_use_subcommand" -s c
complete -c my-app -n "__fish_use_subcommand" -s v
complete -c my-app -n "__fish_use_subcommand" -s h -l help -d 'Print help'
complete -c my-app -n "__fish_use_subcommand" -f -a "test" -d 'Subcommand'
complete -c my-app -n "__fish_use_subcommand" -f -a "test" -d 'Subcommand
with a second line'
complete -c my-app -n "__fish_use_subcommand" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
complete -c my-app -n "__fish_seen_subcommand_from test" -s d
complete -c my-app -n "__fish_seen_subcommand_from test" -s c
complete -c my-app -n "__fish_seen_subcommand_from test" -s h -l help -d 'Print help'
complete -c my-app -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from test; and not __fish_seen_subcommand_from help" -f -a "test" -d 'Subcommand'
complete -c my-app -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from test; and not __fish_seen_subcommand_from help" -f -a "test" -d 'Subcommand
with a second line'
complete -c my-app -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from test; and not __fish_seen_subcommand_from help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
6 changes: 4 additions & 2 deletions clap_complete/tests/snapshots/basic.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ Register-ArgumentCompleter -Native -CommandName 'my-app' -ScriptBlock {
[CompletionResult]::new('-v', 'v', [CompletionResultType]::ParameterName, 'v')
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('test', 'test', [CompletionResultType]::ParameterValue, 'Subcommand')
[CompletionResult]::new('test', 'test', [CompletionResultType]::ParameterValue, 'Subcommand
with a second line')
[CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)')
break
}
Expand All @@ -37,7 +38,8 @@ Register-ArgumentCompleter -Native -CommandName 'my-app' -ScriptBlock {
break
}
'my-app;help' {
[CompletionResult]::new('test', 'test', [CompletionResultType]::ParameterValue, 'Subcommand')
[CompletionResult]::new('test', 'test', [CompletionResultType]::ParameterValue, 'Subcommand
with a second line')
[CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)')
break
}
Expand Down
6 changes: 4 additions & 2 deletions clap_complete/tests/snapshots/basic.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,17 @@ esac
(( $+functions[_my-app_commands] )) ||
_my-app_commands() {
local commands; commands=(
'test:Subcommand' \
'test:Subcommand
with a second line' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'my-app commands' commands "$@"
}
(( $+functions[_my-app__help_commands] )) ||
_my-app__help_commands() {
local commands; commands=(
'test:Subcommand' \
'test:Subcommand
with a second line' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'my-app help commands' commands "$@"
Expand Down
6 changes: 4 additions & 2 deletions clap_complete/tests/snapshots/custom_bin_name.elvish
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ set edit:completion:arg-completer[bin-name] = {|@words|
cand -v 'v'
cand -h 'Print help'
cand --help 'Print help'
cand test 'Subcommand'
cand test 'Subcommand
with a second line'
cand help 'Print this message or the help of the given subcommand(s)'
}
&'bin-name;test'= {
Expand All @@ -32,7 +33,8 @@ set edit:completion:arg-completer[bin-name] = {|@words|
cand --help 'Print help'
}
&'bin-name;help'= {
cand test 'Subcommand'
cand test 'Subcommand
with a second line'
cand help 'Print this message or the help of the given subcommand(s)'
}
&'bin-name;help;test'= {
Expand Down
6 changes: 4 additions & 2 deletions clap_complete/tests/snapshots/custom_bin_name.fish
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
complete -c bin-name -n "__fish_use_subcommand" -s c
complete -c bin-name -n "__fish_use_subcommand" -s v
complete -c bin-name -n "__fish_use_subcommand" -s h -l help -d 'Print help'
complete -c bin-name -n "__fish_use_subcommand" -f -a "test" -d 'Subcommand'
complete -c bin-name -n "__fish_use_subcommand" -f -a "test" -d 'Subcommand
with a second line'
complete -c bin-name -n "__fish_use_subcommand" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
complete -c bin-name -n "__fish_seen_subcommand_from test" -s d
complete -c bin-name -n "__fish_seen_subcommand_from test" -s c
complete -c bin-name -n "__fish_seen_subcommand_from test" -s h -l help -d 'Print help'
complete -c bin-name -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from test; and not __fish_seen_subcommand_from help" -f -a "test" -d 'Subcommand'
complete -c bin-name -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from test; and not __fish_seen_subcommand_from help" -f -a "test" -d 'Subcommand
with a second line'
complete -c bin-name -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from test; and not __fish_seen_subcommand_from help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
6 changes: 4 additions & 2 deletions clap_complete/tests/snapshots/custom_bin_name.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ Register-ArgumentCompleter -Native -CommandName 'bin-name' -ScriptBlock {
[CompletionResult]::new('-v', 'v', [CompletionResultType]::ParameterName, 'v')
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('test', 'test', [CompletionResultType]::ParameterValue, 'Subcommand')
[CompletionResult]::new('test', 'test', [CompletionResultType]::ParameterValue, 'Subcommand
with a second line')
[CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)')
break
}
Expand All @@ -37,7 +38,8 @@ Register-ArgumentCompleter -Native -CommandName 'bin-name' -ScriptBlock {
break
}
'bin-name;help' {
[CompletionResult]::new('test', 'test', [CompletionResultType]::ParameterValue, 'Subcommand')
[CompletionResult]::new('test', 'test', [CompletionResultType]::ParameterValue, 'Subcommand
with a second line')
[CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)')
break
}
Expand Down
6 changes: 4 additions & 2 deletions clap_complete/tests/snapshots/custom_bin_name.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,17 @@ esac
(( $+functions[_bin-name_commands] )) ||
_bin-name_commands() {
local commands; commands=(
'test:Subcommand' \
'test:Subcommand
with a second line' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'bin-name commands' commands "$@"
}
(( $+functions[_bin-name__help_commands] )) ||
_bin-name__help_commands() {
local commands; commands=(
'test:Subcommand' \
'test:Subcommand
with a second line' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'bin-name help commands' commands "$@"
Expand Down
12 changes: 7 additions & 5 deletions clap_complete/tests/testsuite/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ pub fn basic_command(name: &'static str) -> clap::Command {
.action(clap::ArgAction::SetTrue),
)
.subcommand(
clap::Command::new("test").about("Subcommand").arg(
clap::Arg::new("debug")
.short('d')
.action(clap::ArgAction::Count),
),
clap::Command::new("test")
.about("Subcommand\nwith a second line")
.arg(
clap::Arg::new("debug")
.short('d')
.action(clap::ArgAction::Count),
),
)
}

Expand Down
12 changes: 7 additions & 5 deletions clap_complete_fig/tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ pub fn basic_command(name: &'static str) -> clap::Command {
.action(clap::ArgAction::SetTrue),
)
.subcommand(
clap::Command::new("test").about("Subcommand").arg(
clap::Arg::new("debug")
.short('d')
.action(clap::ArgAction::Count),
),
clap::Command::new("test")
.about("Subcommand\nwith a second line")
.arg(
clap::Arg::new("debug")
.short('d')
.action(clap::ArgAction::Count),
),
)
}

Expand Down
4 changes: 2 additions & 2 deletions clap_complete_fig/tests/snapshots/basic.fig.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const completion: Fig.Spec = {
subcommands: [
{
name: "test",
description: "Subcommand",
description: "Subcommand with a second line",
options: [
{
name: "-d",
Expand All @@ -25,7 +25,7 @@ const completion: Fig.Spec = {
subcommands: [
{
name: "test",
description: "Subcommand",
description: "Subcommand with a second line",
},
{
name: "help",
Expand Down
4 changes: 2 additions & 2 deletions clap_complete_nushell/tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub fn basic_command(name: &'static str) -> Command {
)
.subcommand(
Command::new("test")
.about("Subcommand")
.about("Subcommand\nwith a second line")
.arg(Arg::new("debug").short('d').action(ArgAction::Count)),
)
}
Expand All @@ -36,7 +36,7 @@ pub fn feature_sample_command(name: &'static str) -> Command {
.arg(
Arg::new("config")
.action(ArgAction::Count)
.help("some config file")
.help("some config file\nwith another line")
.short('c')
.visible_short_alias('C')
.long("config")
Expand Down
2 changes: 2 additions & 0 deletions clap_complete_nushell/tests/snapshots/basic.nu
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module completions {
]

# Subcommand
with a second line
export extern "my-app test" [
-d
-c
Expand All @@ -18,6 +19,7 @@ module completions {
]

# Subcommand
with a second line
export extern "my-app help test" [
]

Expand Down
3 changes: 3 additions & 0 deletions clap_complete_nushell/tests/snapshots/feature_sample.nu
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ module completions {
export extern my-app [
file?: string # some input file
--config(-c) # some config file
with another line
--conf # some config file
with another line
-C # some config file
with another line
choice?: string@"nu-complete my-app choice"
--help(-h) # Print help
--version(-V) # Print version
Expand Down
3 changes: 3 additions & 0 deletions clap_complete_nushell/tests/snapshots/special_commands.nu
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ module completions {
export extern my-app [
file?: string # some input file
--config(-c) # some config file
with another line
--conf # some config file
with another line
-C # some config file
with another line
choice?: string@"nu-complete my-app choice"
--help(-h) # Print help
--version(-V) # Print version
Expand Down
3 changes: 3 additions & 0 deletions clap_complete_nushell/tests/snapshots/sub_subcommands.nu
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ module completions {
export extern my-app [
file?: string # some input file
--config(-c) # some config file
with another line
--conf # some config file
with another line
-C # some config file
with another line
choice?: string@"nu-complete my-app choice"
--help(-h) # Print help
--version(-V) # Print version
Expand Down
12 changes: 7 additions & 5 deletions clap_mangen/tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ pub fn basic_command(name: &'static str) -> clap::Command {
.action(clap::ArgAction::SetTrue),
)
.subcommand(
clap::Command::new("test").about("Subcommand").arg(
clap::Arg::new("debug")
.short('d')
.action(clap::ArgAction::Count),
),
clap::Command::new("test")
.about("Subcommand\nwith a second line")
.arg(
clap::Arg::new("debug")
.short('d')
.action(clap::ArgAction::Count),
),
)
}

Expand Down
1 change: 1 addition & 0 deletions clap_mangen/tests/snapshots/basic.bash.roff
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Print help
.TP
my\-app\-test(1)
Subcommand
with a second line
.TP
my\-app\-help(1)
Print this message or the help of the given subcommand(s)

0 comments on commit fba7c85

Please sign in to comment.