diff options
| author | demo <demo@antix1> | 2026-05-29 10:24:27 -0400 |
|---|---|---|
| committer | demo <demo@antix1> | 2026-05-29 10:24:27 -0400 |
| commit | 5fdc04709975732733bf0ddc1308ea25c0cb453a (patch) | |
| tree | 33f436a58139ed1e36a96af7398d417b488f2186 /main.go | |
| parent | 5b03eac7cb9e7b5c736e217d8a63b4ac14af28be (diff) | |
refactor: funnel business logic into bespoke functions
This way:
1. We don't have to stuff all our business logic where urfave is set
up.
2. Our functions aren't forced to use the signature required by the
Action field.
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -5,6 +5,7 @@ import ( "fmt" "log" "os" + "strings" "github.com/urfave/cli/v3" ) @@ -18,8 +19,10 @@ func main() { 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 + args := cmd.Args().Slice() + task := strings.Join(args, " ") + + return cmdAdd(task) }, }, { @@ -43,8 +46,7 @@ func main() { return fmt.Errorf("invalid 'do' argument: %d", taskIndex) } - fmt.Println("completed task: ", taskIndex) - return nil + return cmdDo(taskIndex) }, }, { @@ -52,8 +54,7 @@ func main() { Aliases: []string{"l"}, Usage: "list pending tasks", Action: func(ctx context.Context, cmd *cli.Command) error { - fmt.Println("listed pending tasks") - return nil + return cmdList() }, }, }, |
