Skip to content

Commit 3b6f814

Browse files
authored
Fix .postTerminator usage message (#542)
* Fix synopsis for .postTerminator parsing strategy * Add test for .postTerminator usage message generation
1 parent 255ef66 commit 3b6f814

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Sources/ArgumentParser/Usage/UsageGenerator.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ extension ArgumentDefinition {
116116
if help.options.contains(.isOptional) {
117117
synopsis = "[\(synopsis)]"
118118
}
119+
if parsingStrategy == .postTerminator {
120+
synopsis = "-- \(synopsis)"
121+
}
119122
return synopsis
120123
}
121124
}

Tests/ArgumentParserUnitTests/UsageGenerationTests.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,4 +217,13 @@ extension UsageGenerationTests {
217217
_testSynopsis(N.self, expected: "example [--a] [--b]")
218218
_testSynopsis(N.self, visibility: .hidden, expected: "example [--a] [--b]")
219219
}
220+
221+
struct O: ParsableArguments {
222+
@Argument var a: String
223+
@Argument(parsing: .postTerminator) var b: [String] = []
224+
}
225+
226+
func testSynopsisWithPostTerminatorParsingStrategy() {
227+
_testSynopsis(O.self, expected: "example <a> -- [<b> ...]")
228+
}
220229
}

0 commit comments

Comments
 (0)