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

package person

import (
	"fmt"

	"github.com/spf13/cobra"
)

// AddCmd creates a new person. Exported for potential use by shortcuts.
var AddCmd = &cobra.Command{
	Use:   "add FIRST LAST",
	Short: "Add a new person",
	Args:  cobra.ExactArgs(2),
	RunE: func(cmd *cobra.Command, args []string) error {
		// TODO: implement person creation
		fmt.Fprintf(cmd.OutOrStdout(), "Adding person: %s %s (not yet implemented)\n", args[0], args[1])

		return nil
	},
}

func init() {
	AddCmd.Flags().StringP("relationship", "r", "", "Relationship strength")

	_ = AddCmd.RegisterFlagCompletionFunc("relationship", completeRelationships)
}

// completeRelationships returns relationship strength options for shell completion.
func completeRelationships(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
	return []string{
		"family",
		"intimate-friends",
		"close-friends",
		"casual-friends",
		"acquaintances",
		"business-contacts",
		"almost-strangers",
	}, cobra.ShellCompDirectiveNoFileComp
}
