Skip to content

Commit 11df8d8

Browse files
Tweak spacing help text in error message when validation fails
Co-authored-by: Nate Cook <[email protected]>
1 parent 1813147 commit 11df8d8

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

Sources/ArgumentParser/Usage/MessageInfo.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ enum MessageInfo {
134134
case .help(text: let text):
135135
return text
136136
case .validation(message: let message, usage: let usage, help: let help):
137-
let helpMessage = help.isEmpty ? "" : "Help: \(help)\n"
137+
let helpMessage = help.isEmpty ? "" : "Help: \(help)\n"
138138
let errorMessage = message.isEmpty ? "" : "\(args._errorLabel): \(message)\n"
139139
return errorMessage + helpMessage + usage
140140
case .other(let message, _):

Sources/ArgumentParser/Usage/UsageGenerator.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,9 @@ extension ErrorMessageGenerator {
388388

389389
switch (name, valueName) {
390390
case let (n?, v?):
391-
return "\(n.synopsisString) <\(v)> \(abstract)"
391+
return "\(n.synopsisString) <\(v)> \(abstract)"
392392
case let (_, v?):
393-
return "<\(v)> \(abstract)"
393+
return "<\(v)> \(abstract)"
394394
case (_, _):
395395
return ""
396396
}

Tests/ArgumentParserEndToEndTests/TransformEndToEndTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fileprivate struct FooOption: Convert, ParsableArguments {
4040
Usage: foo_option --string <int_str>
4141
See 'foo_option --help' for more information.
4242
"""
43-
static var help: String = "Help: --string <int_str> Convert string to integer\n"
43+
static var help: String = "Help: --string <int_str> Convert string to integer\n"
4444

4545
@Option(help: ArgumentHelp("Convert string to integer", valueName: "int_str"),
4646
transform: { try convert($0) })
@@ -53,7 +53,7 @@ fileprivate struct BarOption: Convert, ParsableCommand {
5353
Usage: bar-option [--strings <int_str> ...]
5454
See 'bar-option --help' for more information.
5555
"""
56-
static var help: String = "Help: --strings <int_str> Convert a list of strings to an array of integers\n"
56+
static var help: String = "Help: --strings <int_str> Convert a list of strings to an array of integers\n"
5757

5858
@Option(help: ArgumentHelp("Convert a list of strings to an array of integers", valueName: "int_str"),
5959
transform: { try convert($0) })
@@ -103,7 +103,7 @@ fileprivate struct FooArgument: Convert, ParsableArguments {
103103
Usage: foo_argument <int_str>
104104
See 'foo_argument --help' for more information.
105105
"""
106-
static var help: String = "Help: <int_str> Convert string to integer\n"
106+
static var help: String = "Help: <int_str> Convert string to integer\n"
107107

108108
enum FooError: Error {
109109
case outOfBounds
@@ -120,7 +120,7 @@ fileprivate struct BarArgument: Convert, ParsableCommand {
120120
Usage: bar-argument [<int_str> ...]
121121
See 'bar-argument --help' for more information.
122122
"""
123-
static var help: String = "Help: <int_str> Convert a list of strings to an array of integers\n"
123+
static var help: String = "Help: <int_str> Convert a list of strings to an array of integers\n"
124124

125125
@Argument(help: ArgumentHelp("Convert a list of strings to an array of integers", valueName: "int_str"),
126126
transform: { try convert($0) })

Tests/ArgumentParserExampleTests/MathExampleTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ final class MathExampleTests: XCTestCase {
167167
command: "math ZZZ",
168168
expected: """
169169
Error: The value 'ZZZ' is invalid for '<values>'
170-
Help: <values> A group of integers to operate on.
170+
Help: <values> A group of integers to operate on.
171171
Usage: math add [--hex-output] [<values> ...]
172172
See 'math add --help' for more information.
173173
""",

Tests/ArgumentParserExampleTests/RepeatExampleTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ final class RepeatExampleTests: XCTestCase {
7373
command: "repeat hello --count ZZZ",
7474
expected: """
7575
Error: The value 'ZZZ' is invalid for '--count <count>'
76-
Help: --count <count> The number of times to repeat 'phrase'.
76+
Help: --count <count> The number of times to repeat 'phrase'.
7777
Usage: repeat [--count <count>] [--include-counter] <phrase>
7878
See 'repeat --help' for more information.
7979
""",

Tests/ArgumentParserExampleTests/RollDiceExampleTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ final class RollDiceExampleTests: XCTestCase {
4949
command: "roll --times ZZZ",
5050
expected: """
5151
Error: The value 'ZZZ' is invalid for '--times <n>'
52-
Help: --times <n> Rolls the dice <n> times.
52+
Help: --times <n> Rolls the dice <n> times.
5353
Usage: roll [--times <n>] [--sides <m>] [--seed <seed>] [--verbose]
5454
See 'roll --help' for more information.
5555
""",

0 commit comments

Comments
 (0)