package main import ( "context" "fmt" "log" "os" "github.com/urfave/cli/v3" ) func main() { cmd := &cli.Command{ 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 }, }, { 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 }, }, }, } if err := cmd.Run(context.Background(), os.Args); err != nil { log.Fatal(err) } }