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

package note

import (
	"fmt"

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

// AddCmd creates a new note. Exported for potential use by shortcuts.
var AddCmd = &cobra.Command{
	Use:   "add [NAME]",
	Short: "Create a new note",
	Long: `Create a new note in Lunatask.

Use "-" as content flag value to read from stdin.`,
	RunE: func(cmd *cobra.Command, args []string) error {
		// TODO: implement note creation
		name := ""
		if len(args) > 0 {
			name = args[0]
		}
		fmt.Fprintf(cmd.OutOrStdout(), "Creating note: %s (not yet implemented)\n", name)

		return nil
	},
}

func init() {
	AddCmd.Flags().StringP("notebook", "b", "", "Notebook key (from config)")
	AddCmd.Flags().StringP("content", "c", "", "Note content (use - for stdin)")

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