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

Method Run

internal/cmd/appscript.go:192–242  ·  view source on GitHub ↗
(ctx context.Context, flags *RootFlags)

Source from the content-addressed store, hash-verified

190}
191
192func (c *AppScriptCreateCmd) Run(ctx context.Context, flags *RootFlags) error {
193 title := strings.TrimSpace(c.Title)
194 if title == "" {
195 return usage("empty --title")
196 }
197 parentID := strings.TrimSpace(normalizeGoogleID(c.ParentID))
198
199 if dryRunErr := dryRunExit(ctx, flags, "appscript.create", map[string]any{
200 "title": title,
201 "parent_id": parentID,
202 }); dryRunErr != nil {
203 return dryRunErr
204 }
205
206 account, err := requireAccount(flags)
207 if err != nil {
208 return err
209 }
210
211 svc, err := appScriptService(ctx, account)
212 if err != nil {
213 return err
214 }
215 project, err := svc.Projects.Create(&scriptapi.CreateProjectRequest{
216 Title: title,
217 ParentId: parentID,
218 }).Context(ctx).Do()
219 if err != nil {
220 return err
221 }
222
223 if outfmt.IsJSON(ctx) {
224 return outfmt.WriteJSON(ctx, stdoutWriter(ctx), map[string]any{
225 "created": true,
226 "project": project,
227 "editor_url": appScriptEditURL(project.ScriptId),
228 })
229 }
230
231 u := ui.FromContext(ctx)
232 u.Out().Linef("created\ttrue")
233 u.Out().Linef("script_id\t%s", project.ScriptId)
234 if project.Title != "" {
235 u.Out().Linef("title\t%s", project.Title)
236 }
237 if project.ParentId != "" {
238 u.Out().Linef("parent_id\t%s", project.ParentId)
239 }
240 u.Out().Linef("editor_url\t%s", appScriptEditURL(project.ScriptId))
241 return nil
242}
243
244func parseJSONArray(raw string) ([]interface{}, error) {
245 val := strings.TrimSpace(raw)

Callers

nothing calls this directly

Calls 14

IsJSONFunction · 0.92
WriteJSONFunction · 0.92
FromContextFunction · 0.92
usageFunction · 0.85
normalizeGoogleIDFunction · 0.85
dryRunExitFunction · 0.85
requireAccountFunction · 0.85
appScriptServiceFunction · 0.85
stdoutWriterFunction · 0.85
appScriptEditURLFunction · 0.85
CreateMethod · 0.80
LinefMethod · 0.80

Tested by

no test coverage detected