summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.go64
1 files changed, 33 insertions, 31 deletions
diff --git a/main.go b/main.go
index 079ccc5..26bbce2 100644
--- a/main.go
+++ b/main.go
@@ -5,45 +5,47 @@ import (
"fmt"
"log"
"os"
- "strings"
"github.com/urfave/cli/v3"
)
func main() {
cmd := &cli.Command{
- Flags: []cli.Flag{
- &cli.StringFlag{
- Name: "lang",
- Value: "en",
- Usage: "language used for the greeting",
+ Commands: []*cli.Command{
+ {
+
+ Name: "add",
+ Aliases: []string{"a"},
+ Usage: "add a task to the list",
+ Action: func(ctx context.Context, cmd *cli.Command) error {
+ fmt.Println("added task: ", cmd.Args().Slice())
+ return nil
+ },
},
- &cli.IntFlag{
- Name: "times",
- Value: 1,
- Usage: "number of times to repeat word for hello",
+ {
+ Name: "do",
+ Aliases: []string{"d"},
+ Usage: "complete a task on the list",
+ Arguments: []cli.Argument{
+ &cli.IntArg{
+ Name: "taskIndex",
+ },
+ },
+ Action: func(ctx context.Context, cmd *cli.Command) error {
+ taskIndex := cmd.IntArg("taskIndex")
+ fmt.Println("completed task: ", taskIndex)
+ return nil
+ },
+ },
+ {
+ Name: "list",
+ Aliases: []string{"l"},
+ Usage: "list pending tasks",
+ Action: func(ctx context.Context, cmd *cli.Command) error {
+ fmt.Println("listed pending tasks")
+ return nil
+ },
},
- },
- Usage: "top level application",
- Action: func(ctx context.Context, cmd *cli.Command) error {
- name := "Brandon"
- if cmd.NArg() > 0 {
- name = cmd.Args().First()
- }
-
- dir := map[string]string{
- "es": "Hola",
- "en": "Hello",
- }
-
- greeting, ok := dir[cmd.String("lang")]
- if !ok {
- greeting = "???"
- }
-
- fmt.Printf("%s, %s\n", strings.Repeat(greeting, cmd.Int("times")), name)
-
- return nil
},
}