in Sources/ArgumentParser/Completions/ZshCompletionsGenerator.swift [166:191]
func zshActionString(_ commands: [ParsableCommand.Type]) -> String {
switch completion.kind {
case .default:
return ""
case .file(let extensions):
let pattern = extensions.isEmpty
? ""
: " -g '\(extensions.map { "*." + $0 }.joined(separator: " "))'"
return "_files\(pattern.zshEscaped())"
case .directory:
return "_files -/"
case .list(let list):
return "(" + list.joined(separator: " ") + ")"
case .shellCommand(let command):
return "{local -a list; list=(${(f)\"$(\(command))\"}); _describe '''' list}"
case .custom:
// Generate a call back into the command to retrieve a completions list
let commandName = commands.first!._commandName.zshEscapingCommandName()
return "{_custom_completion $_\(commandName)_commandname \(customCompletionCall(commands)) $words}"
}
}