- Update workonCmd to accept todo_item_title arg and add -f/--fix, -c/--complete flags - Implement transactional flow: bootstrap todo dirs, move/create .md files, create branch, append Grok-generated Work Plan, commit - Add todo package with Bootstrap for directory structure - Expand workon.Run to handle modes (todo, fix, complete) with placeholders for Grok integration and optional cnadd/IDE open
51 lines
1.6 KiB
Go
51 lines
1.6 KiB
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"gmgauthier.com/grokkit/internal/logger"
|
|
"gmgauthier.com/grokkit/internal/workon"
|
|
)
|
|
|
|
var workonCmd = &cobra.Command{
|
|
Use: "workon <todo_item_title>",
|
|
Short: "Start or complete work on a todo item or fix",
|
|
Long: `workon automates starting or completing a todo/fix:
|
|
- Moves queued todo to doing/ or creates new fix .md
|
|
- Creates matching git branch
|
|
- Generates + appends "Work Plan" via Grok
|
|
- Commits to the branch
|
|
- Optional: cnadd log + open in configured IDE
|
|
|
|
Purely transactional. See todo/doing/workon.md for full spec.`,
|
|
Args: cobra.ExactArgs(1),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
title := strings.ReplaceAll(args[0], " ", "-")
|
|
customMsg, _ := cmd.Flags().GetString("message")
|
|
isFix, _ := cmd.Flags().GetBool("fix")
|
|
isComplete, _ := cmd.Flags().GetBool("complete")
|
|
|
|
if isComplete && (isFix || customMsg != "") {
|
|
return fmt.Errorf("-c cannot be combined with -f or -m")
|
|
}
|
|
|
|
logger.Info("workon starting", "title", title, "fix", isFix, "complete", isComplete)
|
|
|
|
if err := workon.Run(title, customMsg, isFix, isComplete); err != nil {
|
|
return fmt.Errorf("workon failed: %w", err)
|
|
}
|
|
|
|
logger.Info("workon completed successfully")
|
|
return nil
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
workonCmd.Flags().StringP("message", "m", "", "Custom commit message (default: \"Start working on <todo_item_title>\")")
|
|
workonCmd.Flags().BoolP("fix", "f", false, "Treat as fix instead of todo (create new .md in doing/)")
|
|
workonCmd.Flags().BoolP("complete", "c", false, "Complete the item (move to completed/; exclusive)")
|
|
}
|