File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
Sources/ArgumentParser/Usage Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -150,7 +150,7 @@ internal struct HelpGenerator {
150150 i += 1
151151
152152 } else {
153- let defaultValue = arg. help. defaultValue. flatMap { " (default: \( $0) ) " } ?? " "
153+ let defaultValue = arg. help. defaultValue. flatMap { $0 . isEmpty ? nil : " (default: \( $0) ) " } ?? " "
154154 synopsis = arg. synopsisForHelp ?? " "
155155 description = [ arg. help. help? . abstract, defaultValue]
156156 . compactMap { $0 }
Original file line number Diff line number Diff line change @@ -80,15 +80,21 @@ extension HelpGenerationTests {
8080 var two : String
8181 @Option ( help: " The third option " )
8282 var three : String
83+ @Option ( default: nil , help: " A fourth option " )
84+ var four : String ?
85+ @Option ( default: " " , help: " A fifth option " )
86+ var five : String
8387 }
8488
8589 func testHelpWithDefaultValueButNoDiscussion( ) {
8690 AssertHelp ( for: Issue27 . self, equals: """
87- USAGE: issue27 [--two <two>] --three <three>
91+ USAGE: issue27 [--two <two>] --three <three> [--four <four>] [--five <five>]
8892
8993 OPTIONS:
9094 --two <two> (default: 42)
9195 --three <three> The third option
96+ --four <four> A fourth option
97+ --five <five> A fifth option
9298 -h, --help Show help information.
9399
94100 """ )
You can’t perform that action at this time.
0 commit comments