-
Notifications
You must be signed in to change notification settings - Fork 6
/
root.go
30 lines (23 loc) · 1.02 KB
/
root.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
package cli
import (
"github.com/spf13/cobra"
)
var CmdRoot = NewCmd[ShowHelp](nil, "anchor", func(cmd *cobra.Command) {
cfg := ConfigFromCmd(cmd)
cmd.PersistentFlags().StringVar(&cfg.API.Token, "api-token", Defaults.API.Token, "Anchor API personal access token (PAT).")
cmd.PersistentFlags().StringVar(&cfg.API.URL, "api-url", Defaults.API.URL, "Anchor API endpoint URL.")
cmd.PersistentFlags().StringVar(&cfg.File.Path, "config", Defaults.File.Path, "Service configuration file.")
cmd.PersistentFlags().StringVar(&cfg.Dashboard.URL, "dashboard-url", Defaults.Dashboard.URL, "Anchor dashboard URL.")
cmd.PersistentFlags().BoolVar(&cfg.File.Skip, "skip-config", Defaults.File.Skip, "Skip loading configuration file.")
if err := cmd.PersistentFlags().MarkHidden("api-url"); err != nil {
panic(err)
}
if err := cmd.PersistentFlags().MarkHidden("dashboard-url"); err != nil {
panic(err)
}
})
// ShowHelp calls cmd.HelpFunc() inside RunE instead of RunTUI
type ShowHelp struct{}
func (c ShowHelp) UI() UI {
return UI{}
}