Skip to content

Commit fc5109d

Browse files
committed
Adding custom usage template
1 parent 1c98149 commit fc5109d

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

run.go

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ func Run(ctx context.Context, cliargs []string) error {
7575
c.SetVersionTemplate("{{ .Name }} {{ .Version }}\n")
7676
c.SetArgs(cliargs[1:])
7777
c.SilenceErrors = true
78+
c.SetUsageTemplate(text.UsageTemplate)
7879

7980
flags := c.Flags()
8081
flags.SortFlags = false

text/text.go

+8
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ var (
9393
NotificationReceived = `Asynchronous notification %q %sreceived from server process with PID %d.`
9494
NotificationPayload = `with payload %q `
9595
UnknownShortAlias = `(unk)`
96+
UsageTemplate = `Usage: {{.UseLine}}
97+
98+
Args:
99+
DSN database url
100+
101+
Flags:
102+
{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}
103+
`
96104
)
97105

98106
func init() {

0 commit comments

Comments
 (0)