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

Method Run

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

Source from the content-addressed store, hash-verified

134}
135
136func (c *SheetsConditionalClearCmd) Run(ctx context.Context, flags *RootFlags) error {
137 spreadsheetID := normalizeGoogleID(strings.TrimSpace(c.SpreadsheetID))
138 sheetName := strings.TrimSpace(c.Sheet)
139 if spreadsheetID == "" {
140 return usage("empty spreadsheetId")
141 }
142 if sheetName == "" {
143 return usage("empty --sheet")
144 }
145 if !c.All && strings.TrimSpace(c.Index) == "" {
146 return usage("provide --index or --all")
147 }
148 if c.All && strings.TrimSpace(c.Index) != "" {
149 return usage("use either --index or --all, not both")
150 }
151 if err := sheetsconditional.ValidateClearIndex(strings.TrimSpace(c.Index)); err != nil {
152 return sheetsConditionalPlannerError(err)
153 }
154
155 if flags != nil && flags.DryRun {
156 return dryRunAndConfirmDestructive(ctx, flags, "sheets.conditional-format.clear", map[string]any{
157 "spreadsheet_id": spreadsheetID,
158 "sheet": sheetName,
159 "index": strings.TrimSpace(c.Index),
160 "all": c.All,
161 }, "remove conditional format rules from "+sheetName)
162 }
163
164 account, err := requireAccount(flags)
165 if err != nil {
166 return err
167 }
168 svc, err := sheetsService(ctx, account)
169 if err != nil {
170 return err
171 }
172 resp, err := svc.Spreadsheets.Get(spreadsheetID).
173 Fields("sheets(properties(sheetId,title),conditionalFormats)").
174 Context(ctx).
175 Do()
176 if err != nil {
177 return err
178 }
179 sheetID, count, err := sheetsconditional.SheetRuleCount(resp, sheetName)
180 if err != nil {
181 return sheetsConditionalPlannerError(err)
182 }
183
184 requests, err := sheetsconditional.BuildDeleteRequests(sheetID, count, strings.TrimSpace(c.Index), c.All)
185 if err != nil {
186 return sheetsConditionalPlannerError(err)
187 }
188 if len(requests) == 0 {
189 if outfmt.IsJSON(ctx) {
190 return outfmt.WriteJSON(ctx, stdoutWriter(ctx), map[string]any{"removed": 0})
191 }
192 ui.FromContext(ctx).Out().Println("No conditional format rules to remove")
193 return nil

Callers

nothing calls this directly

Calls 15

ValidateClearIndexFunction · 0.92
SheetRuleCountFunction · 0.92
BuildDeleteRequestsFunction · 0.92
IsJSONFunction · 0.92
WriteJSONFunction · 0.92
FromContextFunction · 0.92
normalizeGoogleIDFunction · 0.85
usageFunction · 0.85
requireAccountFunction · 0.85
sheetsServiceFunction · 0.85

Tested by

no test coverage detected