checkpoint: define top level flag for config dir
This commit is contained in:
parent
ecc8d51c09
commit
1b76ceb4da
4 changed files with 14 additions and 3 deletions
|
@ -15,3 +15,7 @@ func (a *accountNames) Set(value string) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
type topLevelFlags struct {
|
||||
configDir string
|
||||
}
|
||||
|
|
|
@ -88,6 +88,10 @@ func run() error {
|
|||
unblock: "unblock a resource (e.g. an account)",
|
||||
}
|
||||
|
||||
globals := topLevelFlags{}
|
||||
|
||||
flag.StringVar(&globals.configDir, "config-dir", "", "specify your config directory")
|
||||
|
||||
flag.Usage = enbasUsageFunc(summaries)
|
||||
|
||||
flag.Parse()
|
||||
|
@ -119,7 +123,7 @@ func run() error {
|
|||
case updateResource:
|
||||
executor = newUpdateCommand(updateResource, summaries[updateResource])
|
||||
case whoami:
|
||||
executor = newWhoAmICommand(whoami, summaries[whoami])
|
||||
executor = newWhoAmICommand(globals, whoami, summaries[whoami])
|
||||
case add:
|
||||
executor = newAddCommand(add, summaries[add])
|
||||
case remove:
|
||||
|
|
|
@ -9,11 +9,14 @@ import (
|
|||
|
||||
type whoAmICommand struct {
|
||||
*flag.FlagSet
|
||||
|
||||
globals topLevelFlags
|
||||
}
|
||||
|
||||
func newWhoAmICommand(name, summary string) *whoAmICommand {
|
||||
func newWhoAmICommand(globals topLevelFlags, name, summary string) *whoAmICommand {
|
||||
command := whoAmICommand{
|
||||
FlagSet: flag.NewFlagSet(name, flag.ExitOnError),
|
||||
globals: globals,
|
||||
}
|
||||
|
||||
command.Usage = commandUsageFunc(name, summary, command.FlagSet)
|
||||
|
|
Loading…
Reference in a new issue