From 90d9df9ba6ad492325ca563dc23fd0c350901793 Mon Sep 17 00:00:00 2001 From: Matteo Campinoti Date: Sun, 16 Oct 2022 17:22:56 +0200 Subject: [PATCH 1/3] CompletionsCommand - fix fish completions Quote command name for -a argument --- src/cleo/commands/completions_command.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cleo/commands/completions_command.py b/src/cleo/commands/completions_command.py index 7d67fa0a..560ed14a 100644 --- a/src/cleo/commands/completions_command.py +++ b/src/cleo/commands/completions_command.py @@ -249,7 +249,7 @@ def sanitize(s: str) -> str: command_name = shell_quote(cmd.name) if " " in cmd.name else cmd.name cmds.append( f"complete -c {script_name} -f -n '__fish{function}_no_subcommand' " - f"-a {command_name} -d '{sanitize(cmd.description)}'" + f"-a '{command_name}' -d '{sanitize(cmd.description)}'" ) cmds_opts += [ f"# {command_name}", From 4376dd0cd0824a1b100f0ea4e5ef756c5bf73c4c Mon Sep 17 00:00:00 2001 From: Matteo Campinoti Date: Sun, 16 Oct 2022 18:12:53 +0200 Subject: [PATCH 2/3] CompletionsCommand - use cmd.name directly for fish completion -a argument --- src/cleo/commands/completions_command.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cleo/commands/completions_command.py b/src/cleo/commands/completions_command.py index 560ed14a..ddf95f9c 100644 --- a/src/cleo/commands/completions_command.py +++ b/src/cleo/commands/completions_command.py @@ -249,7 +249,7 @@ def sanitize(s: str) -> str: command_name = shell_quote(cmd.name) if " " in cmd.name else cmd.name cmds.append( f"complete -c {script_name} -f -n '__fish{function}_no_subcommand' " - f"-a '{command_name}' -d '{sanitize(cmd.description)}'" + f"-a '{cmd.name}' -d '{sanitize(cmd.description)}'" ) cmds_opts += [ f"# {command_name}", From 33c4ea3091aca5c0a32cfdd59360ec8eff3805d6 Mon Sep 17 00:00:00 2001 From: Matteo Campinoti Date: Sun, 16 Oct 2022 18:13:15 +0200 Subject: [PATCH 3/3] tests/completions/fish - update fish.txt with quoted commands in -a arguments --- tests/commands/completion/fixtures/fish.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/commands/completion/fixtures/fish.txt b/tests/commands/completion/fixtures/fish.txt index 57c02809..8eeafde2 100644 --- a/tests/commands/completion/fixtures/fish.txt +++ b/tests/commands/completion/fixtures/fish.txt @@ -17,10 +17,10 @@ complete -c script -n '__fish_my_function_no_subcommand' -l verbose -d 'Increase complete -c script -n '__fish_my_function_no_subcommand' -l version -d 'Display this application version.' # commands -complete -c script -f -n '__fish_my_function_no_subcommand' -a command:with:colons -d 'Test.' -complete -c script -f -n '__fish_my_function_no_subcommand' -a hello -d 'Complete me please.' -complete -c script -f -n '__fish_my_function_no_subcommand' -a help -d 'Displays help for a command.' -complete -c script -f -n '__fish_my_function_no_subcommand' -a list -d 'Lists commands.' +complete -c script -f -n '__fish_my_function_no_subcommand' -a 'command:with:colons' -d 'Test.' +complete -c script -f -n '__fish_my_function_no_subcommand' -a 'hello' -d 'Complete me please.' +complete -c script -f -n '__fish_my_function_no_subcommand' -a 'help' -d 'Displays help for a command.' +complete -c script -f -n '__fish_my_function_no_subcommand' -a 'list' -d 'Lists commands.' complete -c script -f -n '__fish_my_function_no_subcommand' -a 'spaced command' -d 'Command with space in name.' # command options