(ctx context.Context, flags *RootFlags, docID, text string)
| 120 | } |
| 121 | |
| 122 | func (c *DocsWriteCmd) writePlainText(ctx context.Context, flags *RootFlags, docID, text string) error { |
| 123 | if c.Append && c.Format.createsBullets() && c.Format.hasParagraphStyle() { |
| 124 | return usage("docs write --append cannot combine bullet creation with paragraph formatting; append first, then use docs format") |
| 125 | } |
| 126 | if c.Format.any() { |
| 127 | if _, err := c.Format.buildRequests(1, 1+utf16Len(text), c.Tab); err != nil { |
| 128 | return err |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | dryRunPayload := map[string]any{ |
| 133 | "document_id": docID, |
| 134 | "written": len(text), |
| 135 | "append": c.Append, |
| 136 | "replace": !c.Append, |
| 137 | "markdown": false, |
| 138 | "pageless": c.Pageless, |
| 139 | "tab": c.Tab, |
| 140 | "batch": c.Batch, |
| 141 | } |
| 142 | for k, v := range c.Layout.dryRunPayload() { |
| 143 | dryRunPayload[k] = v |
| 144 | } |
| 145 | if err := dryRunExit(ctx, flags, "docs.write", dryRunPayload); err != nil { |
| 146 | return err |
| 147 | } |
| 148 | if err := validateDocsBatchTarget(ctx, flags, c.Batch, docID); err != nil { |
| 149 | return err |
| 150 | } |
| 151 | |
| 152 | svc, err := requireDocsService(ctx, flags) |
| 153 | if err != nil { |
| 154 | return err |
| 155 | } |
| 156 | batchRevision, err := captureDocsBatchRevision(ctx, svc, c.Batch, docID) |
| 157 | if err != nil { |
| 158 | return err |
| 159 | } |
| 160 | |
| 161 | endIndex, tabID, err := docsTargetEndIndexAndTabID(ctx, svc, docID, c.Tab) |
| 162 | if err != nil { |
| 163 | return err |
| 164 | } |
| 165 | c.Tab = tabID |
| 166 | insertIndex := int64(1) |
| 167 | if c.Append { |
| 168 | insertIndex = docsedit.AppendIndex(endIndex) |
| 169 | } |
| 170 | |
| 171 | reqs, err := docsedit.BuildWriteRequests(docsedit.WriteOptions{ |
| 172 | EndIndex: endIndex, |
| 173 | InsertIndex: insertIndex, |
| 174 | Text: text, |
| 175 | TabID: c.Tab, |
| 176 | Append: c.Append, |
| 177 | Format: c.Format.options(), |
| 178 | }) |
| 179 | if err != nil { |
no test coverage detected