add.go

 1// SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
 2//
 3// SPDX-License-Identifier: AGPL-3.0-or-later
 4
 5package person
 6
 7import (
 8	"fmt"
 9
10	"github.com/spf13/cobra"
11)
12
13// AddCmd creates a new person. Exported for potential use by shortcuts.
14var AddCmd = &cobra.Command{
15	Use:   "add FIRST LAST",
16	Short: "Add a new person",
17	Args:  cobra.ExactArgs(2),
18	RunE: func(cmd *cobra.Command, args []string) error {
19		// TODO: implement person creation
20		fmt.Fprintf(cmd.OutOrStdout(), "Adding person: %s %s (not yet implemented)\n", args[0], args[1])
21
22		return nil
23	},
24}
25
26func init() {
27	AddCmd.Flags().StringP("relationship", "r", "", "Relationship strength")
28
29	_ = AddCmd.RegisterFlagCompletionFunc("relationship", completeRelationships)
30}
31
32// completeRelationships returns relationship strength options for shell completion.
33func completeRelationships(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
34	return []string{
35		"family",
36		"intimate-friends",
37		"close-friends",
38		"casual-friends",
39		"acquaintances",
40		"business-contacts",
41		"almost-strangers",
42	}, cobra.ShellCompDirectiveNoFileComp
43}