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