From 6edfa5c461eacae8b358acd116c9215aa205f64b Mon Sep 17 00:00:00 2001 From: Erik Winter Date: Thu, 31 Oct 2024 07:26:03 +0100 Subject: [PATCH] wip --- plan/command/command.go | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/plan/command/command.go b/plan/command/command.go index 30bac06..24c62b2 100644 --- a/plan/command/command.go +++ b/plan/command/command.go @@ -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 { + + } }