list.go

 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	"github.com/spf13/cobra"
11)
12
13// ListCmd lists tasks. Exported for potential use by shortcuts.
14var ListCmd = &cobra.Command{
15	Use:   "list",
16	Short: "List tasks",
17	Long: `List tasks from Lunatask.
18
19Note: Due to end-to-end encryption, task names and notes
20are not available through the API. Only metadata is shown.`,
21	RunE: func(cmd *cobra.Command, _ []string) error {
22		// TODO: implement task listing
23		fmt.Fprintln(cmd.OutOrStdout(), "Task listing not yet implemented")
24
25		return nil
26	},
27}
28
29func init() {
30	ListCmd.Flags().StringP("area", "a", "", "Filter by area key")
31	ListCmd.Flags().StringP("status", "s", "", "Filter by status")
32	ListCmd.Flags().Bool("json", false, "Output as JSON")
33
34	_ = ListCmd.RegisterFlagCompletionFunc("area", completeAreas)
35	_ = ListCmd.RegisterFlagCompletionFunc("status",
36		func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
37			return []string{"later", "next", "started", "waiting", "completed"}, cobra.ShellCompDirectiveNoFileComp
38		})
39}