-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcmd_contacts.go
More file actions
41 lines (34 loc) · 1 KB
/
cmd_contacts.go
File metadata and controls
41 lines (34 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"fmt"
"os"
"github.com/spf13/cobra"
)
func init() {
contactsCmd := &cobra.Command{
Use: "contacts",
Short: "Deprecated: use 'frm list --all' instead",
Hidden: true,
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Fprintln(os.Stderr, "Warning: 'frm contacts' is deprecated, use 'frm list --all' instead.")
// Find the list command and invoke it with --all
listCmd, _, err := rootCmd.Find([]string{"list"})
if err != nil {
return fmt.Errorf("finding list command: %w", err)
}
// Set the --all flag on the list command
if err := listCmd.Flags().Set("all", "true"); err != nil {
return fmt.Errorf("setting --all flag: %w", err)
}
// Forward the --json flag if set
jsonFlag, _ := cmd.Flags().GetBool("json")
if jsonFlag {
if err := listCmd.Flags().Set("json", "true"); err != nil {
return fmt.Errorf("setting --json flag: %w", err)
}
}
return listCmd.RunE(listCmd, args)
},
}
rootCmd.AddCommand(contactsCmd)
}