MCPcopy Create free account
hub / github.com/GetStream/stream-cli / listCmd

Function listCmd

pkg/cmd/chat/device/device.go:67–99  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

65}
66
67func listCmd() *cobra.Command {
68 cmd := &cobra.Command{
69 Use: "list-devices --user-id [user-id] --output-format [json|tree]",
70 Short: "List devices",
71 Long: "Provides a list of all devices associated with a user.",
72 Example: heredoc.Doc(`
73 # List devices for a user
74 $ stream-cli chat list-devices --user-id "my-user-id"
75 `),
76 RunE: func(cmd *cobra.Command, args []string) error {
77 c, err := config.GetConfig(cmd).GetClient(cmd)
78 if err != nil {
79 return err
80 }
81
82 userID, _ := cmd.Flags().GetString("user-id")
83
84 devices, err := c.GetDevices(cmd.Context(), userID)
85 if err != nil {
86 return err
87 }
88
89 return utils.PrintObject(cmd, devices.Devices)
90 },
91 }
92
93 fl := cmd.Flags()
94 fl.StringP("user-id", "u", "", "[required] User ID")
95 fl.StringP("output-format", "o", "json", "[optional] Output format. Can be json or tree")
96 _ = cmd.MarkFlagRequired("user-id")
97
98 return cmd
99}
100
101func deleteCmd() *cobra.Command {
102 cmd := &cobra.Command{

Callers 1

NewCmdsFunction · 0.70

Calls 3

GetConfigFunction · 0.92
PrintObjectFunction · 0.92
GetClientMethod · 0.80

Tested by

no test coverage detected