update.go

 1// SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
 2//
 3// SPDX-License-Identifier: AGPL-3.0-or-later
 4
 5package task
 6
 7import (
 8	"fmt"
 9
10	"git.secluded.site/lune/internal/completion"
11	"git.secluded.site/lune/internal/validate"
12	"github.com/spf13/cobra"
13)
14
15// UpdateCmd updates a task. Exported for potential use by shortcuts.
16var UpdateCmd = &cobra.Command{
17	Use:   "update ID",
18	Short: "Update a task",
19	Args:  cobra.ExactArgs(1),
20	RunE: func(cmd *cobra.Command, args []string) error {
21		id, err := validate.Reference(args[0])
22		if err != nil {
23			return err
24		}
25
26		// TODO: implement task update
27		fmt.Fprintf(cmd.OutOrStdout(), "Updating task %s (not yet implemented)\n", id)
28
29		return nil
30	},
31}
32
33func init() {
34	UpdateCmd.Flags().String("name", "", "New task name")
35	UpdateCmd.Flags().StringP("area", "a", "", "Move to area key")
36	UpdateCmd.Flags().StringP("goal", "g", "", "Move to goal key")
37	UpdateCmd.Flags().StringP("status", "s", "", "Status: later, next, started, waiting, completed")
38	UpdateCmd.Flags().StringP("note", "n", "", "Task note (use - for stdin)")
39	UpdateCmd.Flags().IntP("priority", "p", 0, "Priority: -2 to 2")
40	UpdateCmd.Flags().IntP("estimate", "e", 0, "Estimate in minutes (0-720)")
41	UpdateCmd.Flags().StringP("motivation", "m", "", "Motivation: must, should, want")
42	UpdateCmd.Flags().Int("eisenhower", 0, "Eisenhower quadrant: 1-4")
43	UpdateCmd.Flags().String("schedule", "", "Schedule date (natural language)")
44
45	_ = UpdateCmd.RegisterFlagCompletionFunc("area", completion.Areas)
46	_ = UpdateCmd.RegisterFlagCompletionFunc("goal", completion.Goals)
47	_ = UpdateCmd.RegisterFlagCompletionFunc("status",
48		completion.Static("later", "next", "started", "waiting", "completed"))
49	_ = UpdateCmd.RegisterFlagCompletionFunc("motivation",
50		completion.Static("must", "should", "want"))
51	_ = UpdateCmd.RegisterFlagCompletionFunc("eisenhower",
52		completion.Static("1", "2", "3", "4"))
53}