This commit is contained in:
Erik Winter 2024-11-01 07:31:21 +01:00
parent 6edfa5c461
commit 555616edee
3 changed files with 42 additions and 16 deletions

View File

@ -20,36 +20,37 @@ type Flag struct {
type Command struct { type Command struct {
Name string Name string
LocalID int
Type CommandType
Description string Description string
Flags []*Flag Flags []*Flag
Action func([]*Flag) error Action func([]*Flag) error
Default bool
} }
type CLI struct { type CLI struct {
cmds []*Command CMDS []*Command
} }
func (cli *CLI) ParseArg(args []string) *Command { func (cli *CLI) Run(args []string) *Command {
name, args := args[0], args[1:] if len(args) == 0 {
args = []string{"list"}
}
cmds := cli.collection id, err := strconv.Atoi(args[0])
id, err := strconv.Atoi(name)
if err == nil { if err == nil {
name, args = args[0], args[1:] args = args[1:]
cmds = cli.single }
if len(args) == 0 {
args = []string{"show"}
} }
for _, c := range cmds { for _, c := range cli.CMDS {
if c.Name == name { if c.Name == name {
c.LocalID = id
return c return c
} }
} }
flags := make([]*Flag, 0, len(args)) // flags := make([]*Flag, 0, len(args))
for _, arg := range args { // for _, arg := range args {
} // }
} }

View File

@ -1 +1,25 @@
package command_test package command_test
import (
"testing"
"go-mod.ewintr.nl/planner/plan/command"
)
func TestCommand(t *testing.T) {
t.Parallel()
for _, tc := range []struct {
name string
args string
exp *command.Command
}{
{
name: "default",
},
} {
t.Run(tc.name, func(t *testing.T) {
})
}
}

1
plan/command/show.go Normal file
View File

@ -0,0 +1 @@
package command