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

Method Run

internal/cmd/docs_table_pin_header.go:17–56  ·  view source on GitHub ↗
(ctx context.Context, flags *RootFlags)

Source from the content-addressed store, hash-verified

15}
16
17func (c *DocsTablePinHeaderCmd) Run(ctx context.Context, flags *RootFlags) error {
18 docID, err := validateDocsTableMutationArgs(c.DocID, c.Table)
19 if err != nil {
20 return err
21 }
22 if c.Rows < 0 {
23 return usage("--rows must be >= 0")
24 }
25 if dryRunErr := dryRunExit(ctx, flags, "docs.table-row.pin-header", map[string]any{
26 "documentId": docID,
27 "table": c.Table,
28 "rows": c.Rows,
29 "tab": c.Tab,
30 }); dryRunErr != nil {
31 return dryRunErr
32 }
33
34 svc, loaded, selected, err := loadDocsSelectedTables(ctx, flags, docID, c.Tab, c.Table)
35 if err != nil {
36 return err
37 }
38 requests := make([]*docs.Request, 0, len(selected))
39 results := make([]docsTableRowActionResult, 0, len(selected))
40 for _, target := range selected {
41 rowCount := int64(len(target.table.TableRows))
42 if c.Rows > rowCount {
43 return usagef("cannot pin %d header rows in table %d (table has %d rows)", c.Rows, target.index, rowCount)
44 }
45 requests = append(requests, &docs.Request{PinTableHeaderRows: &docs.PinTableHeaderRowsRequest{
46 TableStartLocation: &docs.Location{Index: target.startIdx, TabId: loaded.tabID},
47 PinnedHeaderRowsCount: c.Rows,
48 ForceSendFields: []string{"PinnedHeaderRowsCount"},
49 }})
50 results = append(results, docsTableRowActionResult{TableIndex: target.index, Value: c.Rows})
51 }
52 if _, err := executeDocsTableRequests(ctx, svc, docID, loaded.full.RevisionId, requests); err != nil {
53 return fmt.Errorf("pin table header rows: %w", err)
54 }
55 return writeDocsTableRowActionResult(ctx, docID, loaded.tabID, "pin-header", "rows", results)
56}

Calls 8

usageFunction · 0.85
dryRunExitFunction · 0.85
loadDocsSelectedTablesFunction · 0.85
usagefFunction · 0.85
executeDocsTableRequestsFunction · 0.85
ErrorfMethod · 0.80