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

package note

import (
	"fmt"

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

// UpdateCmd updates a note. Exported for potential use by shortcuts.
var UpdateCmd = &cobra.Command{
	Use:   "update ID",
	Short: "Update a note",
	Args:  cobra.ExactArgs(1),
	RunE: func(cmd *cobra.Command, args []string) error {
		id, err := validate.Reference(args[0])
		if err != nil {
			return err
		}

		// TODO: implement note update
		fmt.Fprintf(cmd.OutOrStdout(), "Updating note %s (not yet implemented)\n", id)

		return nil
	},
}

func init() {
	UpdateCmd.Flags().String("name", "", "New note name")
	UpdateCmd.Flags().StringP("notebook", "b", "", "Move to notebook key")
	UpdateCmd.Flags().StringP("content", "c", "", "Note content (use - for stdin)")
	UpdateCmd.Flags().StringP("date", "d", "", "Note date (natural language)")

	_ = UpdateCmd.RegisterFlagCompletionFunc("notebook", completion.Notebooks)
}
