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

Function createCmd

pkg/cmd/chat/channeltype/channeltype.go:59–103  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

57}
58
59func createCmd() *cobra.Command {
60 cmd := &cobra.Command{
61 Use: "create-channel-type --properties [raw-json-properties]",
62 Short: "Create channel type",
63 Long: heredoc.Doc(`
64 This command creates a new channel type. The 'properties' are raw JSON string.
65 The available properties can be found in the Go SDK's 'ChannelType' struct.
66 `),
67 Example: heredoc.Doc(`
68 # Create a new channel type called my-ch-type
69 $ stream-cli chat create-channel-type -p "{\"name\": \"my-ch-type\"}"
70
71 # Create a new channel type called reactionless with reactions disabled
72 $ stream-cli chat create-channel-type -p "{\"name\": \"reactionless\", \"reactions\": false}"
73 `),
74 RunE: func(cmd *cobra.Command, args []string) error {
75 c, err := config.GetConfig(cmd).GetClient(cmd)
76 if err != nil {
77 return err
78 }
79
80 properties, _ := cmd.Flags().GetString("properties")
81
82 ct := &stream.ChannelType{ChannelConfig: stream.DefaultChannelConfig}
83 err = json.Unmarshal([]byte(properties), ct)
84 if err != nil {
85 return err
86 }
87
88 _, err = c.CreateChannelType(cmd.Context(), ct)
89 if err != nil {
90 return err
91 }
92
93 cmd.Println("Successfully created channel type.")
94 return nil
95 },
96 }
97
98 fl := cmd.Flags()
99 fl.StringP("properties", "p", "", "[required] Raw JSON properties")
100 _ = cmd.MarkFlagRequired("properties")
101
102 return cmd
103}
104
105func deleteCmd() *cobra.Command {
106 return &cobra.Command{

Callers 1

NewCmdsFunction · 0.70

Calls 2

GetConfigFunction · 0.92
GetClientMethod · 0.80

Tested by

no test coverage detected