update.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	"git.secluded.site/lune/internal/validate"
12	"github.com/spf13/cobra"
13)
14
15// UpdateCmd updates a note. Exported for potential use by shortcuts.
16var UpdateCmd = &cobra.Command{
17	Use:   "update ID",
18	Short: "Update a note",
19	Args:  cobra.ExactArgs(1),
20	RunE: func(cmd *cobra.Command, args []string) error {
21		id, err := validate.Reference(args[0])
22		if err != nil {
23			return err
24		}
25
26		// TODO: implement note update
27		fmt.Fprintf(cmd.OutOrStdout(), "Updating note %s (not yet implemented)\n", id)
28
29		return nil
30	},
31}
32
33func init() {
34	UpdateCmd.Flags().String("name", "", "New note name")
35	UpdateCmd.Flags().StringP("notebook", "b", "", "Move to notebook key")
36	UpdateCmd.Flags().StringP("content", "c", "", "Note content (use - for stdin)")
37	UpdateCmd.Flags().StringP("date", "d", "", "Note date (natural language)")
38
39	_ = UpdateCmd.RegisterFlagCompletionFunc("notebook", completion.Notebooks)
40}