add.go

 1// SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
 2//
 3// SPDX-License-Identifier: AGPL-3.0-or-later
 4
 5package note
 6
 7import (
 8	"fmt"
 9
10	"git.secluded.site/lune/internal/completion"
11	"github.com/spf13/cobra"
12)
13
14// AddCmd creates a new note. Exported for potential use by shortcuts.
15var AddCmd = &cobra.Command{
16	Use:   "add [NAME]",
17	Short: "Create a new note",
18	Long: `Create a new note in Lunatask.
19
20Use "-" as content flag value to read from stdin.`,
21	RunE: func(cmd *cobra.Command, args []string) error {
22		// TODO: implement note creation
23		name := ""
24		if len(args) > 0 {
25			name = args[0]
26		}
27		fmt.Fprintf(cmd.OutOrStdout(), "Creating note: %s (not yet implemented)\n", name)
28
29		return nil
30	},
31}
32
33func init() {
34	AddCmd.Flags().StringP("notebook", "b", "", "Notebook key (from config)")
35	AddCmd.Flags().StringP("content", "c", "", "Note content (use - for stdin)")
36
37	_ = AddCmd.RegisterFlagCompletionFunc("notebook", completion.Notebooks)
38}