(ctx context.Context, flags *RootFlags, command docsTableDimensionCommand)
| 188 | } |
| 189 | |
| 190 | func 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 | |
| 238 | func (c *DocsTableMergeCmd) Run(ctx context.Context, flags *RootFlags) error { |
| 239 | startRow, startCol, endRow, endCol, err := parseDocsTableRange(c.Range) |
no test coverage detected