diff options
| author | brettlangdon <[email protected]> | 2015-11-07 09:39:23 -0500 |
|---|---|---|
| committer | brettlangdon <[email protected]> | 2015-11-07 09:39:23 -0500 |
| commit | 383b8b84c14efaee9a36415704aaa8c22a167836 (patch) | |
| tree | e2ffe6b645e6d83873b904104996f200fc131809 | |
| parent | 53364a0be4ce4b3a84cefd6fac452fb953cd5acf (diff) | |
Remove excess trailing whitespace from Usage generation
| -rw-r--r-- | usage.go | 8 | ||||
| -rw-r--r-- | usage_test.go | 4 |
2 files changed, 7 insertions, 5 deletions
@@ -27,10 +27,12 @@ func (p *Parser) WriteUsage(w io.Writer) { } } - fmt.Fprintf(w, "usage: %s ", filepath.Base(os.Args[0])) + fmt.Fprintf(w, "usage: %s", filepath.Base(os.Args[0])) // write the option component of the usage message for _, spec := range options { + // prefix with a space + fmt.Fprint(w, " ") if !spec.required { fmt.Fprint(w, "[") } @@ -38,18 +40,18 @@ func (p *Parser) WriteUsage(w io.Writer) { if !spec.required { fmt.Fprint(w, "]") } - fmt.Fprint(w, " ") } // write the positional component of the usage message for _, spec := range positionals { + // prefix with a space + fmt.Fprint(w, " ") up := strings.ToUpper(spec.long) if spec.multiple { fmt.Fprintf(w, "[%s [%s ...]]", up, up) } else { fmt.Fprint(w, up) } - fmt.Fprint(w, " ") } fmt.Fprint(w, "\n") } diff --git a/usage_test.go b/usage_test.go index 6b8741d..83da1c1 100644 --- a/usage_test.go +++ b/usage_test.go @@ -10,9 +10,9 @@ import ( ) func TestWriteUsage(t *testing.T) { - expectedUsage := "usage: example [--verbose] [--dataset DATASET] [--optimize OPTIMIZE] INPUT [OUTPUT [OUTPUT ...]] \n" + expectedUsage := "usage: example [--verbose] [--dataset DATASET] [--optimize OPTIMIZE] INPUT [OUTPUT [OUTPUT ...]]\n" - expectedHelp := `usage: example [--verbose] [--dataset DATASET] [--optimize OPTIMIZE] INPUT [OUTPUT [OUTPUT ...]] + expectedHelp := `usage: example [--verbose] [--dataset DATASET] [--optimize OPTIMIZE] INPUT [OUTPUT [OUTPUT ...]] positional arguments: input |
