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

Function runDocsTableDimensionCommand

internal/cmd/docs_table_ops.go:190–236  ·  view source on GitHub ↗
(ctx context.Context, flags *RootFlags, command docsTableDimensionCommand)

Source from the content-addressed store, hash-verified

188}
189
190func runDocsTableDimensionCommand(ctx context.Context, flags *RootFlags, command docsTableDimensionCommand) error {
191 docID, err := validateDocsTableMutationArgs(command.docID, command.table)
192 if err != nil {
193 return err
194 }
195 if command.target == 0 && !command.appendAtEnd {
196 return usagef("--%s cannot be 0", command.dimension)
197 }
198 targetValue := any(command.target)
199 if command.appendAtEnd {
200 targetValue = "end"
201 }
202 if dryRunErr := dryRunExit(ctx, flags, command.dryRunOp, map[string]any{
203 "documentId": docID,
204 "table": command.table,
205 string(command.dimension): targetValue,
206 "tab": command.tab,
207 }); dryRunErr != nil {
208 return dryRunErr
209 }
210
211 svc, loaded, selected, err := loadDocsSelectedTables(ctx, flags, docID, command.tab, command.table)
212 if err != nil {
213 return err
214 }
215 requests := make([]*docs.Request, 0, len(selected))
216 results := make([]docsTableMutationResult, 0, len(selected))
217 for _, target := range selected {
218 req, resolved, buildErr := docstable.BuildDimensionRequest(
219 docsTablePlanTarget(target.tableWithIndex),
220 command.dimension,
221 docstable.Action(command.action),
222 command.target,
223 command.appendAtEnd,
224 loaded.tabID,
225 )
226 if buildErr != nil {
227 return usage(buildErr.Error())
228 }
229 requests = append(requests, req)
230 results = append(results, docsTableMutationResult{TableIndex: target.index, Index: resolved})
231 }
232 if _, err := executeDocsTableRequests(ctx, svc, docID, loaded.full.RevisionId, requests); err != nil {
233 return fmt.Errorf("%s table %s: %w", command.action, command.dimension, err)
234 }
235 return writeDocsTableMutationResult(ctx, docID, loaded.tabID, command.action, string(command.dimension), results)
236}
237
238func (c *DocsTableMergeCmd) Run(ctx context.Context, flags *RootFlags) error {
239 startRow, startCol, endRow, endCol, err := parseDocsTableRange(c.Range)

Callers 3

RunMethod · 0.85
RunMethod · 0.85
RunMethod · 0.85

Calls 12

BuildDimensionRequestFunction · 0.92
ActionTypeAlias · 0.92
usagefFunction · 0.85
dryRunExitFunction · 0.85
loadDocsSelectedTablesFunction · 0.85
docsTablePlanTargetFunction · 0.85
usageFunction · 0.85
executeDocsTableRequestsFunction · 0.85
ErrorfMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected