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

Method Run

internal/cmd/sheets_table.go:29–67  ·  view source on GitHub ↗
(ctx context.Context, flags *RootFlags)

Source from the content-addressed store, hash-verified

27}
28
29func (c *SheetsTableListCmd) Run(ctx context.Context, flags *RootFlags) error {
30 u := ui.FromContext(ctx)
31 account, err := requireAccount(flags)
32 if err != nil {
33 return err
34 }
35
36 spreadsheetID := normalizeGoogleID(strings.TrimSpace(c.SpreadsheetID))
37 if spreadsheetID == "" {
38 return usage("empty spreadsheetId")
39 }
40
41 svc, err := sheetsService(ctx, account)
42 if err != nil {
43 return err
44 }
45
46 tables, err := fetchSpreadsheetTables(ctx, svc, spreadsheetID)
47 if err != nil {
48 return err
49 }
50 sort.Slice(tables, func(i, j int) bool {
51 if tables[i].Name == tables[j].Name {
52 return tables[i].TableID < tables[j].TableID
53 }
54 return tables[i].Name < tables[j].Name
55 })
56
57 if outfmt.IsJSON(ctx) {
58 return outfmt.WriteJSON(ctx, stdoutWriter(ctx), map[string]any{"tables": tables})
59 }
60
61 if len(tables) == 0 {
62 u.Err().Println("No tables")
63 return nil
64 }
65
66 return outfmt.WriteTable(ctx, stdoutWriter(ctx), tables, sheetsTableColumns())
67}
68
69type SheetsTableGetCmd struct {
70 SpreadsheetID string `arg:"" name:"spreadsheetId" help:"Spreadsheet ID"`

Callers

nothing calls this directly

Calls 13

FromContextFunction · 0.92
IsJSONFunction · 0.92
WriteJSONFunction · 0.92
WriteTableFunction · 0.92
requireAccountFunction · 0.85
normalizeGoogleIDFunction · 0.85
usageFunction · 0.85
sheetsServiceFunction · 0.85
fetchSpreadsheetTablesFunction · 0.85
stdoutWriterFunction · 0.85
sheetsTableColumnsFunction · 0.85
PrintlnMethod · 0.80

Tested by

no test coverage detected