Skip to content

Commit 88f223c

Browse files
authored
fix(cli): fixed help formatting broken with recent upgrade to kingpin/v2 (kopia#2868)
1 parent d8e6273 commit 88f223c

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

main.go

+31-31
Original file line numberDiff line numberDiff line change
@@ -19,48 +19,48 @@ import (
1919
"github.com/kopia/kopia/repo"
2020
)
2121

22-
const usageTemplate = `{{define "FormatCommand"}}\
23-
{{if .FlagSummary}} {{.FlagSummary}}{{end}}\
24-
{{range .Args}} {{if not .Required}}[{{end}}<{{.Name}}>{{if .Value|IsCumulative}}...{{end}}{{if not .Required}}]{{end}}{{end}}\
25-
{{end}}\
26-
{{define "FormatCommandList"}}\
27-
{{range .}}\
28-
{{if not .Hidden}}\
29-
{{.Depth|Indent}}{{.Name}}{{if .Default}}*{{end}}{{template "FormatCommand" .}}
30-
{{template "FormatCommandList" .Commands}}\
31-
{{end}}\
32-
{{end}}\
33-
{{end}}\
34-
{{define "FormatUsage"}}\
35-
{{template "FormatCommand" .}}{{if .Commands}} <command> [<args> ...]{{end}}
22+
const usageTemplate = `{{define "FormatCommand" -}}
23+
{{if .FlagSummary}} {{.FlagSummary -}}{{end -}}
24+
{{range .Args}} {{if not .Required}}[{{end -}}<{{.Name -}}>{{if .Value|IsCumulative}}...{{end}}{{if not .Required}}]{{end}}{{end -}}
25+
{{end -}}
26+
{{define "FormatCommandList" -}}
27+
{{range . -}}
28+
{{if not .Hidden -}}
29+
{{.Depth|Indent -}}{{.Name -}}{{if .Default -}}*{{end -}}{{template "FormatCommand" .}}
30+
{{template "FormatCommandList" .Commands -}}
31+
{{end -}}
32+
{{end -}}
33+
{{end -}}
34+
{{define "FormatUsage" -}}
35+
{{template "FormatCommand" .}}{{if .Commands}} <command> [<args> ...]{{end -}}
3636
{{if .Help}}
37-
{{.Help|Wrap 0}}\
38-
{{end}}\
39-
{{end}}\
40-
{{if .Context.SelectedCommand}}\
37+
{{.Help|Wrap 0 -}}
38+
{{end -}}
39+
{{end}}
40+
{{if .Context.SelectedCommand -}}
4141
usage: {{.App.Name}} {{.Context.SelectedCommand}}{{template "FormatUsage" .Context.SelectedCommand}}
42-
{{else}}\
42+
{{else -}}
4343
usage: {{.App.Name}}{{template "FormatUsage" .App}}
44-
{{end}}\
45-
{{if .Context.Flags}}\
44+
{{end -}}
45+
{{if .Context.Flags -}}
4646
Flags:
4747
{{.Context.Flags|FlagsToTwoColumns|FormatTwoColumns}}
48-
{{end}}\
49-
{{if .Context.Args}}\
48+
{{end -}}
49+
{{if .Context.Args -}}
5050
Args:
5151
{{.Context.Args|ArgsToTwoColumns|FormatTwoColumns}}
52-
{{end}}\
53-
{{if .Context.SelectedCommand}}\
54-
{{if .Context.SelectedCommand.Commands}}\
52+
{{end -}}
53+
{{if .Context.SelectedCommand -}}
54+
{{if .Context.SelectedCommand.Commands -}}
5555
Subcommands:
5656
{{.Context.SelectedCommand}}
57-
{{template "FormatCommandList" .Context.SelectedCommand.Commands}}
58-
{{end}}\
59-
{{else if .App.Commands}}\
57+
{{template "FormatCommandList" .Context.SelectedCommand.Commands -}}
58+
{{end -}}
59+
{{else if .App.Commands -}}
6060
Commands (use --help-full to list all commands):
6161
62-
{{template "FormatCommandList" .App.Commands}}
63-
{{end}}\
62+
{{template "FormatCommandList" .App.Commands -}}
63+
{{end -}}
6464
`
6565

6666
func main() {

0 commit comments

Comments
 (0)