(ctx context.Context, flags *RootFlags)
| 22 | } |
| 23 | |
| 24 | func (c *DocsTableColumnWidthCmd) Run(ctx context.Context, flags *RootFlags) error { |
| 25 | u := ui.FromContext(ctx) |
| 26 | docID := strings.TrimSpace(c.DocID) |
| 27 | if docID == "" { |
| 28 | return usage("empty docId") |
| 29 | } |
| 30 | if err := c.validate(); err != nil { |
| 31 | return err |
| 32 | } |
| 33 | dryRunPayload := map[string]any{ |
| 34 | "documentId": docID, |
| 35 | "tableIndex": c.TableIndex, |
| 36 | "evenlyDistributed": c.EvenlyDistributed, |
| 37 | "tab": c.Tab, |
| 38 | "batch": c.Batch, |
| 39 | } |
| 40 | if c.Col > 0 { |
| 41 | dryRunPayload["col"] = c.Col |
| 42 | } else { |
| 43 | dryRunPayload["allColumns"] = true |
| 44 | } |
| 45 | if c.Width > 0 { |
| 46 | dryRunPayload["width"] = c.Width |
| 47 | } |
| 48 | if dryRunErr := dryRunExit(ctx, flags, "docs.table-column-width", dryRunPayload); dryRunErr != nil { |
| 49 | return dryRunErr |
| 50 | } |
| 51 | if err := validateDocsBatchTarget(ctx, flags, c.Batch, docID); err != nil { |
| 52 | return err |
| 53 | } |
| 54 | |
| 55 | svc, err := requireDocsService(ctx, flags) |
| 56 | if err != nil { |
| 57 | return err |
| 58 | } |
| 59 | loaded, err := loadDocsTargetDocument(ctx, svc, docID, c.Tab) |
| 60 | if err != nil { |
| 61 | return err |
| 62 | } |
| 63 | c.Tab = loaded.tabID |
| 64 | |
| 65 | table, resolvedTableIndex, err := resolveDocsTableWithIndex(loaded.target, c.TableIndex) |
| 66 | if err != nil { |
| 67 | return err |
| 68 | } |
| 69 | req, err := c.buildRequest(table.startIdx, docsTableColumnCount(table.table), c.Tab) |
| 70 | if err != nil { |
| 71 | return err |
| 72 | } |
| 73 | if queued, queueErr := queueDocsBatchRequests(ctx, flags, c.Batch, docID, "docs.table-column-width", loaded.full.RevisionId, []*docs.Request{req}, false); queued || queueErr != nil { |
| 74 | return queueErr |
| 75 | } |
| 76 | resp, err := svc.Documents.BatchUpdate(docID, &docs.BatchUpdateDocumentRequest{ |
| 77 | WriteControl: &docs.WriteControl{RequiredRevisionId: loaded.full.RevisionId}, |
| 78 | Requests: []*docs.Request{req}, |
| 79 | }).Context(ctx).Do() |
| 80 | if err != nil { |
| 81 | if isDocsNotFound(err) { |
nothing calls this directly
no test coverage detected