1// SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
2//
3// SPDX-License-Identifier: AGPL-3.0-or-later
4
5package habit
6
7import (
8 "fmt"
9
10 "git.secluded.site/lune/internal/completion"
11 "github.com/spf13/cobra"
12)
13
14// TrackCmd tracks a habit activity. Exported for potential use by shortcuts.
15var TrackCmd = &cobra.Command{
16 Use: "track KEY",
17 Short: "Track a habit activity",
18 Long: `Record that a habit was performed.
19
20KEY is the habit key from your config (not the raw Lunatask ID).
21Tracks for today by default. Use --date to specify another date.`,
22 Args: cobra.ExactArgs(1),
23 ValidArgsFunction: completion.Habits,
24 RunE: func(cmd *cobra.Command, args []string) error {
25 date, _ := cmd.Flags().GetString("date")
26 if date == "" {
27 date = "today"
28 }
29
30 // TODO: implement habit tracking
31 fmt.Fprintf(cmd.OutOrStdout(), "Tracking habit %s for %s (not yet implemented)\n", args[0], date)
32
33 return nil
34 },
35}
36
37func init() {
38 TrackCmd.Flags().StringP("date", "d", "", "Date performed (natural language, default: today)")
39}