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

package person

import (
	"fmt"

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

// UpdateCmd updates a person. Exported for potential use by shortcuts.
var UpdateCmd = &cobra.Command{
	Use:   "update ID",
	Short: "Update a person",
	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 person update
		fmt.Fprintf(cmd.OutOrStdout(), "Updating person %s (not yet implemented)\n", id)

		return nil
	},
}

func init() {
	UpdateCmd.Flags().String("first", "", "First name")
	UpdateCmd.Flags().String("last", "", "Last name")
	UpdateCmd.Flags().StringP("relationship", "r", "", "Relationship strength")

	_ = UpdateCmd.RegisterFlagCompletionFunc("relationship", completion.Relationships)
}
