(ctx context.Context, flags *RootFlags)
| 71 | } |
| 72 | |
| 73 | func (c *AppScriptContentCmd) Run(ctx context.Context, flags *RootFlags) error { |
| 74 | account, err := requireAccount(flags) |
| 75 | if err != nil { |
| 76 | return err |
| 77 | } |
| 78 | scriptID := strings.TrimSpace(normalizeGoogleID(c.ScriptID)) |
| 79 | if scriptID == "" { |
| 80 | return usage("empty scriptId") |
| 81 | } |
| 82 | |
| 83 | svc, err := appScriptService(ctx, account) |
| 84 | if err != nil { |
| 85 | return err |
| 86 | } |
| 87 | content, err := svc.Projects.GetContent(scriptID).Context(ctx).Do() |
| 88 | if err != nil { |
| 89 | return err |
| 90 | } |
| 91 | |
| 92 | if outfmt.IsJSON(ctx) { |
| 93 | return outfmt.WriteJSON(ctx, stdoutWriter(ctx), map[string]any{ |
| 94 | "content": content, |
| 95 | }) |
| 96 | } |
| 97 | |
| 98 | u := ui.FromContext(ctx) |
| 99 | u.Out().Linef("script_id\t%s", content.ScriptId) |
| 100 | u.Out().Linef("files\t%d", len(content.Files)) |
| 101 | for _, file := range content.Files { |
| 102 | if file == nil { |
| 103 | continue |
| 104 | } |
| 105 | u.Out().Linef("file\t%s\t%s", file.Name, file.Type) |
| 106 | } |
| 107 | return nil |
| 108 | } |
| 109 | |
| 110 | type AppScriptRunCmd struct { |
| 111 | ScriptID string `arg:"" name:"scriptId" help:"Script ID"` |
nothing calls this directly
no test coverage detected