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 "github.com/spf13/cobra"
12)
13
14// AddCmd creates a new task. Exported for use by the add shortcut.
15var AddCmd = &cobra.Command{
16 Use: "add NAME",
17 Short: "Create a new task",
18 Long: `Create a new task in Lunatask.
19
20The task name is required. Use flags to set additional properties.
21Use "-" as NAME to read the task name from stdin.`,
22 Args: cobra.MinimumNArgs(1),
23 RunE: func(cmd *cobra.Command, args []string) error {
24 // TODO: implement task creation
25 name := args[0]
26 fmt.Fprintf(cmd.OutOrStdout(), "Creating task: %s (not yet implemented)\n", name)
27
28 return nil
29 },
30}
31
32func init() {
33 AddCmd.Flags().StringP("area", "a", "", "Area key (from config)")
34 AddCmd.Flags().StringP("goal", "g", "", "Goal key (from config)")
35 AddCmd.Flags().StringP("status", "s", "", "Status: later, next, started, waiting")
36 AddCmd.Flags().StringP("note", "n", "", "Task note (use - for stdin)")
37 AddCmd.Flags().IntP("priority", "p", 0, "Priority: -2 to 2")
38 AddCmd.Flags().IntP("estimate", "e", 0, "Estimate in minutes (0-720)")
39 AddCmd.Flags().StringP("motivation", "m", "", "Motivation: must, should, want")
40 AddCmd.Flags().Int("eisenhower", 0, "Eisenhower quadrant: 1-4")
41 AddCmd.Flags().String("schedule", "", "Schedule date (natural language)")
42
43 _ = AddCmd.RegisterFlagCompletionFunc("area", completion.Areas)
44 _ = AddCmd.RegisterFlagCompletionFunc("goal", completion.Goals)
45 _ = AddCmd.RegisterFlagCompletionFunc("status",
46 completion.Static("later", "next", "started", "waiting"))
47 _ = AddCmd.RegisterFlagCompletionFunc("motivation",
48 completion.Static("must", "should", "want"))
49 _ = AddCmd.RegisterFlagCompletionFunc("eisenhower",
50 completion.Static("1", "2", "3", "4"))
51}