// SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
//
// SPDX-License-Identifier: AGPL-3.0-or-later

package habit

import (
	"fmt"

	"git.secluded.site/lune/internal/completion"
	"github.com/spf13/cobra"
)

// TrackCmd tracks a habit activity. Exported for potential use by shortcuts.
var TrackCmd = &cobra.Command{
	Use:   "track KEY",
	Short: "Track a habit",
	Long: `Record that a habit was performed.

KEY is the habit key from your config (not the raw Lunatask ID).
Tracks for today by default. Use --date to specify another date.`,
	Args:              cobra.ExactArgs(1),
	ValidArgsFunction: completion.Habits,
	RunE: func(cmd *cobra.Command, args []string) error {
		date, _ := cmd.Flags().GetString("date")
		if date == "" {
			date = "today"
		}

		// TODO: implement habit tracking
		fmt.Fprintf(cmd.OutOrStdout(), "Tracking habit %s for %s (not yet implemented)\n", args[0], date)

		return nil
	},
}

func init() {
	TrackCmd.Flags().StringP("date", "d", "", "Date performed (natural language, default: today)")
}
