-
Notifications
You must be signed in to change notification settings - Fork 0
/
flags.go
36 lines (28 loc) · 887 Bytes
/
flags.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package common
import (
"github.com/spf13/cobra"
)
// FlagsCmd represents the flags command
var FlagsCmd = &cobra.Command{
Use: "flags",
Short: "Display the list of available global flags for all wal-g commands",
DisableFlagsInUseLine: true,
Run: func(cmd *cobra.Command, args []string) {
_ = cmd.Usage()
},
}
func init() {
FlagsCmd.SetUsageTemplate(flagsUsageTemplate)
FlagsCmd.SetHelpTemplate(flagsHelpTemplate)
// fix to disable the required settings check for the help subcommand
FlagsCmd.PersistentPreRun = func(*cobra.Command, []string) {}
}
const flagsHelpTemplate = `{{with (or .Long .Short)}}{{. | trimTrailingWhitespaces}}{{end}}
Usage:
{{.UseLine}}
Flags:
{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}
{{.Usage}}`
const flagsUsageTemplate = `Global Flags:
{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}
`