update.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	"git.secluded.site/lune/internal/completion"
11	"git.secluded.site/lune/internal/validate"
12	"github.com/spf13/cobra"
13)
14
15// UpdateCmd updates a person. Exported for potential use by shortcuts.
16var UpdateCmd = &cobra.Command{
17	Use:   "update ID",
18	Short: "Update a person",
19	Args:  cobra.ExactArgs(1),
20	RunE: func(cmd *cobra.Command, args []string) error {
21		if err := validate.ID(args[0]); err != nil {
22			return err
23		}
24
25		// TODO: implement person update
26		fmt.Fprintf(cmd.OutOrStdout(), "Updating person %s (not yet implemented)\n", args[0])
27
28		return nil
29	},
30}
31
32func init() {
33	UpdateCmd.Flags().String("first", "", "First name")
34	UpdateCmd.Flags().String("last", "", "Last name")
35	UpdateCmd.Flags().StringP("relationship", "r", "", "Relationship strength")
36
37	_ = UpdateCmd.RegisterFlagCompletionFunc("relationship", completion.Relationships)
38}