Compare commits

...

2 Commits

Author SHA1 Message Date
4325398ca8
add usage information to Command struct 2020-08-07 18:11:42 -05:00
39d889ecb6
add name to Command struct 2020-08-07 18:09:54 -05:00

View File

@ -27,6 +27,7 @@ type Command struct {
Name string Name string
Func func(CmdArgs) (int, error) Func func(CmdArgs) (int, error)
Flags *flag.FlagSet Flags *flag.FlagSet
Use string
} }
var commandRegistry = make(map[string]Command) var commandRegistry = make(map[string]Command)
@ -75,6 +76,7 @@ func RegisterCommand(name string, cmd Command) error {
if _, ok := commandRegistry[name]; ok { if _, ok := commandRegistry[name]; ok {
return fmt.Errorf("%s command is already registered") return fmt.Errorf("%s command is already registered")
} }
cmd.Name = name
commandRegistry[name] = cmd commandRegistry[name] = cmd
return nil return nil
} }