File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed
Sources/ArgumentParser/Completions
Tests/ArgumentParserUnitTests Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ struct ZshCompletionsGenerator {
1717 return """
1818 #compdef \( type. _commandName)
1919 local context state state_descr line
20- _ \( type. _commandName) _commandname=$words[1]
20+ _ \( type. _commandName. zshEscapingCommandName ( ) ) _commandname=$words[1]
2121 typeset -A opt_args
2222
2323 \( generateCompletionFunction ( [ type] ) )
@@ -122,6 +122,10 @@ extension String {
122122 fileprivate func zshEscaped( ) -> String {
123123 self . zshEscapingSingleQuotes ( ) . zshEscapingMetacharacters ( )
124124 }
125+
126+ fileprivate func zshEscapingCommandName( ) -> String {
127+ self . replacingOccurrences ( of: " - " , with: " _ " )
128+ }
125129}
126130
127131extension ArgumentDefinition {
Original file line number Diff line number Diff line change @@ -125,13 +125,13 @@ extension CompletionScriptTests {
125125}
126126
127127extension CompletionScriptTests {
128- struct Escaped : ParsableCommand {
128+ struct EscapedCommand : ParsableCommand {
129129 @Option ( help: #"Escaped chars: '[]\."# )
130130 var one : String
131131 }
132132
133133 func testEscaped_Zsh( ) throws {
134- XCTAssertEqual ( zshEscapedCompletion, Escaped . completionScript ( for: . zsh) )
134+ XCTAssertEqual ( zshEscapedCompletion, EscapedCommand . completionScript ( for: . zsh) )
135135 }
136136}
137137
@@ -213,12 +213,12 @@ complete -F _base base
213213"""
214214
215215private let zshEscapedCompletion = """
216- #compdef escaped
216+ #compdef escaped-command
217217local context state state_descr line
218- _escaped_commandname =$words[1]
218+ _escaped_command_commandname =$words[1]
219219typeset -A opt_args
220220
221- _escaped() {
221+ _escaped-command () {
222222 integer ret=1
223223 local -a args
224224 args+=(
@@ -236,7 +236,7 @@ _custom_completion() {
236236 _describe '' completions
237237}
238238
239- _escaped
239+ _escaped-command
240240"""
241241
242242private let fishBaseCompletions = """
You can’t perform that action at this time.
0 commit comments