package command import ( "strconv" ) type CommandType string const ( Single CommandType = "single" Collection CommandType = "collection" ) type Flag struct { Name string Short string Description string Required bool } type Command struct { Name string Description string Flags []*Flag Action func([]*Flag) error Default bool } type CLI struct { CMDS []*Command } func (cli *CLI) Run(args []string) *Command { if len(args) == 0 { args = []string{"list"} } id, err := strconv.Atoi(args[0]) if err == nil { args = args[1:] } if len(args) == 0 { args = []string{"show"} } for _, c := range cli.CMDS { if c.Name == name { return c } } // flags := make([]*Flag, 0, len(args)) // for _, arg := range args { // } }