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

Do not quote spaced commands in ZSH #414

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/360.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Disabled quoting multiple-word completion tokens in ZSH
5 changes: 2 additions & 3 deletions src/cleo/commands/completions_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,13 @@ def sanitize(s: str) -> str:
for cmd in sorted(self.application.all().values(), key=lambda c: c.name or ""):
if cmd.hidden or not (cmd.enabled and cmd.name):
continue
command_name = shell_quote(cmd.name) if " " in cmd.name else cmd.name
cmds.append(self._zsh_describe(command_name, sanitize(cmd.description)))
cmds.append(self._zsh_describe(cmd.name, sanitize(cmd.description)))
options = " ".join(
self._zsh_describe(f"--{opt.name}", sanitize(opt.description))
for opt in sorted(cmd.definition.options, key=lambda o: o.name)
)
cmds_opts += [
f" ({command_name})",
f" ({cmd.name})",
f" opts+=({options})",
" ;;",
"", # newline
Expand Down
4 changes: 2 additions & 2 deletions tests/commands/completion/fixtures/zsh.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ _my_function()
opts+=("--ansi:Force ANSI output." "--help:Display help for the given command. When no command is given display help for the list command." "--no-ansi:Disable ANSI output." "--no-interaction:Do not ask any interactive question." "--quiet:Do not output any message." "--verbose:Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug." "--version:Display this application version.")
elif [[ $cur == $com ]]; then
state="command"
coms+=("command\:with\:colons:Test." "hello:Complete me please." "help:Displays help for a command." "list:Lists commands." "'spaced command':Command with space in name.")
coms+=("command\:with\:colons:Test." "hello:Complete me please." "help:Displays help for a command." "list:Lists commands." "spaced command:Command with space in name.")
fi

case $state in
Expand All @@ -47,7 +47,7 @@ _my_function()
opts+=()
;;

('spaced command')
(spaced command)
opts+=("--goodbye")
;;

Expand Down