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

View File

@ -1 +1,25 @@
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