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

Method Run

internal/cmd/slides_structural.go:209–271  ·  view source on GitHub ↗
(ctx context.Context, flags *RootFlags)

Source from the content-addressed store, hash-verified

207}
208
209func (c *SlidesMoveSlideCmd) Run(ctx context.Context, flags *RootFlags) error {
210 u := ui.FromContext(ctx)
211
212 presentationID := strings.TrimSpace(c.PresentationID)
213 if presentationID == "" {
214 return usage("empty presentationId")
215 }
216 slideID := strings.TrimSpace(c.SlideID)
217 if slideID == "" {
218 return usage("empty slideId")
219 }
220 if c.ToIndex == nil {
221 return usage("--to-index is required")
222 }
223 if *c.ToIndex < 0 {
224 return usage("--to-index must be >= 0")
225 }
226
227 body := &slides.BatchUpdatePresentationRequest{
228 Requests: []*slides.Request{
229 {
230 UpdateSlidesPosition: &slides.UpdateSlidesPositionRequest{
231 SlideObjectIds: []string{slideID},
232 InsertionIndex: *c.ToIndex,
233 ForceSendFields: []string{"InsertionIndex"},
234 },
235 },
236 },
237 }
238 if err := dryRunExit(ctx, flags, "slides.move-slide", map[string]any{
239 "presentation_id": presentationID,
240 "slide_object_id": slideID,
241 "to_index": *c.ToIndex,
242 "batch_update": body,
243 }); err != nil {
244 return err
245 }
246
247 account, err := requireAccount(flags)
248 if err != nil {
249 return err
250 }
251 slidesSvc, err := slidesService(ctx, account)
252 if err != nil {
253 return err
254 }
255 if _, err := slidesSvc.Presentations.BatchUpdate(presentationID, body).Context(ctx).Do(); err != nil {
256 return fmt.Errorf("move slide: %w", err)
257 }
258
259 if outfmt.IsJSON(ctx) {
260 return outfmt.WriteJSON(ctx, stdoutWriter(ctx), map[string]any{
261 "presentationId": presentationID,
262 "slideObjectId": slideID,
263 "toIndex": *c.ToIndex,
264 })
265 }
266

Callers 3

TestSlidesMoveSlideFunction · 0.95
TestSlidesMoveSlideJSONFunction · 0.95

Calls 13

FromContextFunction · 0.92
IsJSONFunction · 0.92
WriteJSONFunction · 0.92
usageFunction · 0.85
dryRunExitFunction · 0.85
requireAccountFunction · 0.85
slidesServiceFunction · 0.85
stdoutWriterFunction · 0.85
ErrorfMethod · 0.80
LinefMethod · 0.80
OutMethod · 0.80
DoMethod · 0.65

Tested by 3

TestSlidesMoveSlideFunction · 0.76
TestSlidesMoveSlideJSONFunction · 0.76