summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authordemo <demo@antix1>2026-05-29 10:24:27 -0400
committerdemo <demo@antix1>2026-05-29 10:24:27 -0400
commit5fdc04709975732733bf0ddc1308ea25c0cb453a (patch)
tree33f436a58139ed1e36a96af7398d417b488f2186 /main.go
parent5b03eac7cb9e7b5c736e217d8a63b4ac14af28be (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.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/main.go b/main.go
index 6472554..96bbcfc 100644
--- a/main.go
+++ b/main.go
@@ -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()
},
},
},