MCPcopy Create free account
hub / github.com/openclaw/gogcli / Run

Method Run

internal/cmd/chat_spaces.go:208–255  ·  view source on GitHub ↗
(ctx context.Context, flags *RootFlags)

Source from the content-addressed store, hash-verified

206}
207
208func (c *ChatSpacesCreateCmd) Run(ctx context.Context, flags *RootFlags) error {
209 u := ui.FromContext(ctx)
210 plan, err := newChatSpaceCreatePlan(chatSpaceCreateInput{
211 DisplayName: c.DisplayName,
212 Members: c.Members,
213 })
214 if err != nil {
215 return err
216 }
217
218 if dryRunErr := dryRunExit(ctx, flags, "chat.spaces.create", plan.dryRunPayload()); dryRunErr != nil {
219 return dryRunErr
220 }
221
222 account, err := requireAccount(flags)
223 if err != nil {
224 return err
225 }
226 if err = requireWorkspaceAccount(account); err != nil {
227 return err
228 }
229
230 svc, err := chatService(ctx, account)
231 if err != nil {
232 return err
233 }
234
235 resp, err := svc.Spaces.Setup(plan.Request).Do()
236 if err != nil {
237 return err
238 }
239
240 if outfmt.IsJSON(ctx) {
241 return outfmt.WriteJSON(ctx, stdoutWriter(ctx), map[string]any{"space": resp})
242 }
243
244 if resp == nil {
245 u.Out().Linef("space\t%s", plan.DisplayName)
246 return nil
247 }
248 if resp.Name != "" {
249 u.Out().Linef("resource\t%s", resp.Name)
250 }
251 if resp.DisplayName != "" {
252 u.Out().Linef("name\t%s", resp.DisplayName)
253 }
254 return nil
255}

Callers

nothing calls this directly

Calls 13

FromContextFunction · 0.92
IsJSONFunction · 0.92
WriteJSONFunction · 0.92
newChatSpaceCreatePlanFunction · 0.85
dryRunExitFunction · 0.85
requireAccountFunction · 0.85
requireWorkspaceAccountFunction · 0.85
chatServiceFunction · 0.85
stdoutWriterFunction · 0.85
LinefMethod · 0.80
OutMethod · 0.80
DoMethod · 0.65

Tested by

no test coverage detected