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

Method Run

internal/cmd/docs_smart_chips.go:85–136  ·  view source on GitHub ↗
(ctx context.Context, flags *RootFlags)

Source from the content-addressed store, hash-verified

83}
84
85func (c *DocsInsertFileChipCmd) Run(ctx context.Context, flags *RootFlags) error {
86 fileID := strings.TrimSpace(c.FileID)
87 if fileID == "" {
88 return usage("empty --file-id")
89 }
90 loc := docsInsertLocationFlags{
91 docID: c.DocID,
92 index: c.Index,
93 atEnd: c.AtEnd,
94 tab: c.Tab,
95 batch: c.Batch,
96 }
97 if dryRunErr := dryRunDocsSingleInsert(ctx, flags, "docs.insert-file-chip", loc, map[string]any{"fileId": fileID}); dryRunErr != nil {
98 return dryRunErr
99 }
100 if err := validateDocsBatchTarget(ctx, flags, c.Batch, c.DocID); err != nil {
101 return err
102 }
103
104 account, err := requireAccount(flags)
105 if err != nil {
106 return err
107 }
108 driveSvc, err := driveService(ctx, account)
109 if err != nil {
110 return err
111 }
112 file, err := driveSvc.Files.Get(fileID).
113 SupportsAllDrives(true).
114 Fields("id,name,mimeType,webViewLink").
115 Context(ctx).
116 Do()
117 if err != nil {
118 return fmt.Errorf("get Drive file: %w", err)
119 }
120 uri := file.WebViewLink
121 if uri == "" {
122 uri = bestEffortWebURL("drive", fileID)
123 }
124 req := &docs.Request{InsertRichLink: &docs.InsertRichLinkRequest{
125 RichLinkProperties: &docs.RichLinkProperties{
126 Uri: uri,
127 },
128 }}
129 return runDocsSingleInsert(ctx, flags, "docs.insert-file-chip", docsInsertLocationFlags{
130 docID: c.DocID,
131 index: c.Index,
132 atEnd: c.AtEnd,
133 tab: c.Tab,
134 batch: c.Batch,
135 }, req, map[string]any{"fileId": fileID, "title": file.Name})
136}
137
138func (c *DocsInsertDateChipCmd) Run(ctx context.Context, flags *RootFlags) error {
139 date := strings.TrimSpace(c.Date)

Callers

nothing calls this directly

Calls 10

usageFunction · 0.85
dryRunDocsSingleInsertFunction · 0.85
validateDocsBatchTargetFunction · 0.85
requireAccountFunction · 0.85
driveServiceFunction · 0.85
bestEffortWebURLFunction · 0.85
runDocsSingleInsertFunction · 0.85
ErrorfMethod · 0.80
DoMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected