Skip to content

Commit a33d4af

Browse files
committed
Updates output for presenting options to a wrapped text block
Arguments switched from a single long line within a preformatted text block to multilines and wrapped to a line length. This makes the output significantly easier to read when there's a large number of options (for example, the `swift build` command). The wrapping algorithm is a simple greedy algorithm that extends up to, but not beyond, a maximum text width. The line length defined by the style of output (markdown - 80, docc - 60) - Snapshot tests for output updated to reflect changes
1 parent 852f74c commit a33d4af

11 files changed

+66
-20
lines changed

Tests/ArgumentParserGenerateDoccReferenceTests/Snapshots/testColorDoccReference().md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ This is optional.
2828
Show subcommand help information.
2929

3030
```
31-
color help [<subcommands>...]
31+
color help [<subcommands>...]
3232
```
3333

3434
- term **subcommands**:

Tests/ArgumentParserGenerateDoccReferenceTests/Snapshots/testColorMarkdownReference().md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ This is optional.
2828
Show subcommand help information.
2929

3030
```
31-
color help [<subcommands>...]
31+
color help [<subcommands>...]
3232
```
3333

3434
**subcommands:**

Tests/ArgumentParserGenerateDoccReferenceTests/Snapshots/testCountLinesDoccReference().md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
<!-- Generated by swift-argument-parser -->
44

55
```
6-
count-lines [<input-file>] [--prefix=<prefix>] [--verbose] [--help]
6+
count-lines [<input-file>] [--prefix=<prefix>] [--verbose]
7+
[--help]
78
```
89

910
- term **input-file**:
@@ -31,7 +32,7 @@ count-lines [<input-file>] [--prefix=<prefix>] [--verbose] [--help]
3132
Show subcommand help information.
3233

3334
```
34-
count-lines help [<subcommands>...]
35+
count-lines help [<subcommands>...]
3536
```
3637

3738
- term **subcommands**:

Tests/ArgumentParserGenerateDoccReferenceTests/Snapshots/testCountLinesMarkdownReference().md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ count-lines [<input-file>] [--prefix=<prefix>] [--verbose] [--help]
3131
Show subcommand help information.
3232

3333
```
34-
count-lines help [<subcommands>...]
34+
count-lines help [<subcommands>...]
3535
```
3636

3737
**subcommands:**

Tests/ArgumentParserGenerateDoccReferenceTests/Snapshots/testMathDoccReference().md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ math add [--hex-output] [<values>...] [--version] [--help]
5353
Print the product of the values.
5454

5555
```
56-
math multiply [--hex-output] [<values>...] [--version] [--help]
56+
math multiply [--hex-output] [<values>...] [--version]
57+
[--help]
5758
```
5859

5960
- term **--hex-output**:
@@ -101,7 +102,8 @@ math stats [--version] [--help]
101102
Print the average of the values.
102103

103104
```
104-
math stats average [--kind=<kind>] [<values>...] [--version] [--help]
105+
math stats average [--kind=<kind>] [<values>...] [--version]
106+
[--help]
105107
```
106108

107109
- term **--kind=\<kind\>**:
@@ -156,7 +158,12 @@ math stats stdev [<values>...] [--version] [--help]
156158
Print the quantiles of the values (TBD).
157159

158160
```
159-
math stats quantiles [<one-of-four>] [<custom-arg>] [<custom-deprecated-arg>] [<values>...] [--file=<file>] [--directory=<directory>] [--shell=<shell>] [--custom=<custom>] [--custom-deprecated=<custom-deprecated>] [--version] [--help]
161+
math stats quantiles [<one-of-four>] [<custom-arg>]
162+
[<custom-deprecated-arg>] [<values>...] [--file=<file>]
163+
[--directory=<directory>] [--shell=<shell>]
164+
[--custom=<custom>]
165+
[--custom-deprecated=<custom-deprecated>] [--version]
166+
[--help]
160167
```
161168

162169
- term **one-of-four**:
@@ -207,7 +214,7 @@ math stats quantiles [<one-of-four>] [<custom-arg>] [<custom-deprecated-arg>] [<
207214
Show subcommand help information.
208215

209216
```
210-
math help [<subcommands>...] [--version]
217+
math help [<subcommands>...] [--version]
211218
```
212219

213220
- term **subcommands**:

Tests/ArgumentParserGenerateDoccReferenceTests/Snapshots/testMathMarkdownReference().md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,10 @@ math stats stdev [<values>...] [--version] [--help]
156156
Print the quantiles of the values (TBD).
157157

158158
```
159-
math stats quantiles [<one-of-four>] [<custom-arg>] [<custom-deprecated-arg>] [<values>...] [--file=<file>] [--directory=<directory>] [--shell=<shell>] [--custom=<custom>] [--custom-deprecated=<custom-deprecated>] [--version] [--help]
159+
math stats quantiles [<one-of-four>] [<custom-arg>] [<custom-deprecated-arg>]
160+
[<values>...] [--file=<file>] [--directory=<directory>] [--shell=<shell>]
161+
[--custom=<custom>] [--custom-deprecated=<custom-deprecated>] [--version]
162+
[--help]
160163
```
161164

162165
**one-of-four:**
@@ -207,7 +210,7 @@ math stats quantiles [<one-of-four>] [<custom-arg>] [<custom-deprecated-arg>] [<
207210
Show subcommand help information.
208211

209212
```
210-
math help [<subcommands>...] [--version]
213+
math help [<subcommands>...] [--version]
211214
```
212215

213216
**subcommands:**

Tests/ArgumentParserGenerateDoccReferenceTests/Snapshots/testRepeatDoccReference().md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
<!-- Generated by swift-argument-parser -->
44

55
```
6-
repeat [--count=<count>] [--include-counter] <phrase> [--help]
6+
repeat [--count=<count>] [--include-counter] <phrase>
7+
[--help]
78
```
89

910
- term **--count=\<count\>**:
@@ -31,7 +32,7 @@ repeat [--count=<count>] [--include-counter] <phrase> [--help]
3132
Show subcommand help information.
3233

3334
```
34-
repeat help [<subcommands>...]
35+
repeat help [<subcommands>...]
3536
```
3637

3738
- term **subcommands**:

Tests/ArgumentParserGenerateDoccReferenceTests/Snapshots/testRepeatMarkdownReference().md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ repeat [--count=<count>] [--include-counter] <phrase> [--help]
3131
Show subcommand help information.
3232

3333
```
34-
repeat help [<subcommands>...]
34+
repeat help [<subcommands>...]
3535
```
3636

3737
**subcommands:**

Tests/ArgumentParserGenerateDoccReferenceTests/Snapshots/testRollDoccReference().md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
<!-- Generated by swift-argument-parser -->
44

55
```
6-
roll [--times=<n>] [--sides=<m>] [--seed=<seed>] [--verbose] [--help]
6+
roll [--times=<n>] [--sides=<m>] [--seed=<seed>] [--verbose]
7+
[--help]
78
```
89

910
- term **--times=\<n\>**:
@@ -38,7 +39,7 @@ Use this option to override the default value of a six-sided die.
3839
Show subcommand help information.
3940

4041
```
41-
roll help [<subcommands>...]
42+
roll help [<subcommands>...]
4243
```
4344

4445
- term **subcommands**:

Tests/ArgumentParserGenerateDoccReferenceTests/Snapshots/testRollMarkdownReference().md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Use this option to override the default value of a six-sided die.
3838
Show subcommand help information.
3939

4040
```
41-
roll help [<subcommands>...]
41+
roll help [<subcommands>...]
4242
```
4343

4444
**subcommands:**

0 commit comments

Comments
 (0)