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 ", 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 \")") 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)") }