Description
Here's an example of an option from Tart, the option has a valueName
that contains a colon:
@Option(help: ArgumentHelp("""
Additional disk attachments with an optional read-only and synchronization options (e.g. --disk="disk.bin", --disk="ubuntu.iso:ro", --disk="/dev/disk0", --disk "ghcr.io/cirruslabs/xcode:16.0:ro" or --disk="nbd://localhost:10809/myDisk:sync=none")
""", valueName: "path[:options]"))
var disk: [String] = []
This is a common notation for Unix-like CLI tools meaning that you can either specify a path
, or additionally have options
, but after a colon.
The resulting Zsh completion looks like this:
_tart_run() {
local -i ret=1
local -ar arg_specs=(
[...]
'*--disk[Additional disk attachments with an optional read-only and synchronization options (e.g. --disk="disk.bin", --disk="ubuntu.iso:ro", --disk="/dev/disk0", --disk "ghcr.io/cirruslabs/xcode:16.0:ro" or --disk="nbd://localhost:10809/myDisk:sync=none")]:path[:options]:'
[...]
)
_arguments -w -s -S : "${arg_specs[@]}" && ret=0
return "${ret}"
}
Here, the colon slips into the completion unescaped, so attempting to complete the tart run --disk
results in the following Zsh error:
% tart run --disk _arguments:465: command not found: options]
Happens on the main
branch of the ArgumentParser.