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

Method Run

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

Source from the content-addressed store, hash-verified

126}
127
128func (c *SheetsTableCreateCmd) Run(ctx context.Context, flags *RootFlags) error {
129 u := ui.FromContext(ctx)
130 spreadsheetID := normalizeGoogleID(strings.TrimSpace(c.SpreadsheetID))
131 rangeSpec := cleanRange(strings.TrimSpace(c.Range))
132 name := strings.TrimSpace(c.Name)
133 if spreadsheetID == "" {
134 return usage("empty spreadsheetId")
135 }
136 if rangeSpec == "" {
137 return usage("empty range")
138 }
139 if name == "" {
140 return usage("empty name")
141 }
142
143 columns, err := parseSheetsTableColumnsJSON(c.ColumnsJSON, stdinReader(ctx))
144 if err != nil {
145 return err
146 }
147
148 if dryRunErr := dryRunExit(ctx, flags, "sheets.table.create", map[string]any{
149 "spreadsheet_id": spreadsheetID,
150 "range": rangeSpec,
151 "name": name,
152 "columns": columns,
153 }); dryRunErr != nil {
154 return dryRunErr
155 }
156
157 account, err := requireAccount(flags)
158 if err != nil {
159 return err
160 }
161
162 svc, err := sheetsService(ctx, account)
163 if err != nil {
164 return err
165 }
166
167 catalog, err := fetchSpreadsheetRangeCatalog(ctx, svc, spreadsheetID)
168 if err != nil {
169 return err
170 }
171 gridRange, err := resolveGridRangeWithCatalog(rangeSpec, catalog, "table")
172 if err != nil {
173 return err
174 }
175
176 table := &sheets.Table{
177 Name: name,
178 Range: gridRange,
179 ColumnProperties: columns,
180 }
181 req := &sheets.BatchUpdateSpreadsheetRequest{
182 Requests: []*sheets.Request{
183 {
184 AddTable: &sheets.AddTableRequest{Table: table},
185 },

Callers

nothing calls this directly

Calls 15

FromContextFunction · 0.92
IsJSONFunction · 0.92
WriteJSONFunction · 0.92
normalizeGoogleIDFunction · 0.85
cleanRangeFunction · 0.85
usageFunction · 0.85
stdinReaderFunction · 0.85
dryRunExitFunction · 0.85
requireAccountFunction · 0.85
sheetsServiceFunction · 0.85

Tested by

no test coverage detected