wip
This commit is contained in:
parent
bca0ac37c4
commit
6edfa5c461
|
@ -1,6 +1,8 @@
|
|||
package command
|
||||
|
||||
import "strconv"
|
||||
import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type CommandType string
|
||||
|
||||
|
@ -18,6 +20,7 @@ type Flag struct {
|
|||
|
||||
type Command struct {
|
||||
Name string
|
||||
LocalID int
|
||||
Type CommandType
|
||||
Description string
|
||||
Flags []*Flag
|
||||
|
@ -25,24 +28,28 @@ type Command struct {
|
|||
}
|
||||
|
||||
type CLI struct {
|
||||
single []*Command
|
||||
collection []*Command
|
||||
cmds []*Command
|
||||
}
|
||||
|
||||
func (cli *CLI) Add(cmd *Command) {
|
||||
if cmd.Type == Single {
|
||||
cli.single = append(cli.single, cmd)
|
||||
return
|
||||
}
|
||||
cli.collection = append(cli.collection, cmd)
|
||||
}
|
||||
func (cli *CLI) ParseArg(args []string) *Command {
|
||||
name, args := args[0], args[1:]
|
||||
|
||||
func ParseArg(args []string) Command {
|
||||
cmd, cmdArgs := args[0], args[1:]
|
||||
|
||||
id, err := strconv.Atoi(cmd)
|
||||
cmds := cli.collection
|
||||
id, err := strconv.Atoi(name)
|
||||
if err == nil {
|
||||
return parseTaskCommand(id, cmdArgs, conf)
|
||||
name, args = args[0], args[1:]
|
||||
cmds = cli.single
|
||||
}
|
||||
|
||||
for _, c := range cmds {
|
||||
if c.Name == name {
|
||||
c.LocalID = id
|
||||
return c
|
||||
}
|
||||
}
|
||||
|
||||
flags := make([]*Flag, 0, len(args))
|
||||
for _, arg := range args {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue