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 {
17
17
return """
18
18
#compdef \( type. _commandName)
19
19
local context state state_descr line
20
- _ \( type. _commandName) _commandname=$words[1]
20
+ _ \( type. _commandName. zshEscapingCommandName ( ) ) _commandname=$words[1]
21
21
typeset -A opt_args
22
22
23
23
\( generateCompletionFunction ( [ type] ) )
@@ -122,6 +122,10 @@ extension String {
122
122
fileprivate func zshEscaped( ) -> String {
123
123
self . zshEscapingSingleQuotes ( ) . zshEscapingMetacharacters ( )
124
124
}
125
+
126
+ fileprivate func zshEscapingCommandName( ) -> String {
127
+ self . replacingOccurrences ( of: " - " , with: " _ " )
128
+ }
125
129
}
126
130
127
131
extension ArgumentDefinition {
Original file line number Diff line number Diff line change @@ -125,13 +125,13 @@ extension CompletionScriptTests {
125
125
}
126
126
127
127
extension CompletionScriptTests {
128
- struct Escaped : ParsableCommand {
128
+ struct EscapedCommand : ParsableCommand {
129
129
@Option ( help: #"Escaped chars: '[]\."# )
130
130
var one : String
131
131
}
132
132
133
133
func testEscaped_Zsh( ) throws {
134
- XCTAssertEqual ( zshEscapedCompletion, Escaped . completionScript ( for: . zsh) )
134
+ XCTAssertEqual ( zshEscapedCompletion, EscapedCommand . completionScript ( for: . zsh) )
135
135
}
136
136
}
137
137
@@ -213,12 +213,12 @@ complete -F _base base
213
213
"""
214
214
215
215
private let zshEscapedCompletion = """
216
- #compdef escaped
216
+ #compdef escaped-command
217
217
local context state state_descr line
218
- _escaped_commandname =$words[1]
218
+ _escaped_command_commandname =$words[1]
219
219
typeset -A opt_args
220
220
221
- _escaped() {
221
+ _escaped-command () {
222
222
integer ret=1
223
223
local -a args
224
224
args+=(
@@ -236,7 +236,7 @@ _custom_completion() {
236
236
_describe '' completions
237
237
}
238
238
239
- _escaped
239
+ _escaped-command
240
240
"""
241
241
242
242
private let fishBaseCompletions = """
You can’t perform that action at this time.
0 commit comments