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

package task

import (
	"fmt"

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

// ListCmd lists tasks. Exported for potential use by shortcuts.
var ListCmd = &cobra.Command{
	Use:   "list",
	Short: "List tasks",
	Long: `List tasks from Lunatask.

Note: Due to end-to-end encryption, task names and notes
are not available through the API. Only metadata is shown.`,
	RunE: func(cmd *cobra.Command, _ []string) error {
		// TODO: implement task listing
		fmt.Fprintln(cmd.OutOrStdout(), "Task listing not yet implemented")

		return nil
	},
}

func init() {
	ListCmd.Flags().StringP("area", "a", "", "Filter by area key")
	ListCmd.Flags().StringP("status", "s", "", "Filter by status")
	ListCmd.Flags().Bool("json", false, "Output as JSON")

	_ = ListCmd.RegisterFlagCompletionFunc("area", completion.Areas)
	_ = ListCmd.RegisterFlagCompletionFunc("status",
		completion.Static("later", "next", "started", "waiting", "completed"))
}
