Skip to content

Commit d2f5230

Browse files
feat(cli): add --raw-output/-r option to print raw (non-JSON) strings
1 parent ed99c1c commit d2f5230

22 files changed

+143
-8
lines changed

pkg/cmd/betaagent.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ func handleBetaAgentsCreate(ctx context.Context, cmd *cli.Command) error {
294294
return ShowJSON(obj, ShowJSONOpts{
295295
ExplicitFormat: explicitFormat,
296296
Format: format,
297+
RawOutput: cmd.Root().Bool("raw-output"),
297298
Title: "beta:agents create",
298299
Transform: transform,
299300
})
@@ -342,6 +343,7 @@ func handleBetaAgentsRetrieve(ctx context.Context, cmd *cli.Command) error {
342343
return ShowJSON(obj, ShowJSONOpts{
343344
ExplicitFormat: explicitFormat,
344345
Format: format,
346+
RawOutput: cmd.Root().Bool("raw-output"),
345347
Title: "beta:agents retrieve",
346348
Transform: transform,
347349
})
@@ -390,6 +392,7 @@ func handleBetaAgentsUpdate(ctx context.Context, cmd *cli.Command) error {
390392
return ShowJSON(obj, ShowJSONOpts{
391393
ExplicitFormat: explicitFormat,
392394
Format: format,
395+
RawOutput: cmd.Root().Bool("raw-output"),
393396
Title: "beta:agents update",
394397
Transform: transform,
395398
})
@@ -430,6 +433,7 @@ func handleBetaAgentsList(ctx context.Context, cmd *cli.Command) error {
430433
return ShowJSON(obj, ShowJSONOpts{
431434
ExplicitFormat: explicitFormat,
432435
Format: format,
436+
RawOutput: cmd.Root().Bool("raw-output"),
433437
Title: "beta:agents list",
434438
Transform: transform,
435439
})
@@ -442,6 +446,7 @@ func handleBetaAgentsList(ctx context.Context, cmd *cli.Command) error {
442446
return ShowJSONIterator(iter, maxItems, ShowJSONOpts{
443447
ExplicitFormat: explicitFormat,
444448
Format: format,
449+
RawOutput: cmd.Root().Bool("raw-output"),
445450
Title: "beta:agents list",
446451
Transform: transform,
447452
})
@@ -491,6 +496,7 @@ func handleBetaAgentsArchive(ctx context.Context, cmd *cli.Command) error {
491496
return ShowJSON(obj, ShowJSONOpts{
492497
ExplicitFormat: explicitFormat,
493498
Format: format,
499+
RawOutput: cmd.Root().Bool("raw-output"),
494500
Title: "beta:agents archive",
495501
Transform: transform,
496502
})

pkg/cmd/betaagentversion.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ func handleBetaAgentsVersionsList(ctx context.Context, cmd *cli.Command) error {
9090
return ShowJSON(obj, ShowJSONOpts{
9191
ExplicitFormat: explicitFormat,
9292
Format: format,
93+
RawOutput: cmd.Root().Bool("raw-output"),
9394
Title: "beta:agents:versions list",
9495
Transform: transform,
9596
})
@@ -107,6 +108,7 @@ func handleBetaAgentsVersionsList(ctx context.Context, cmd *cli.Command) error {
107108
return ShowJSONIterator(iter, maxItems, ShowJSONOpts{
108109
ExplicitFormat: explicitFormat,
109110
Format: format,
111+
RawOutput: cmd.Root().Bool("raw-output"),
110112
Title: "beta:agents:versions list",
111113
Transform: transform,
112114
})

pkg/cmd/betaenvironment.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ func handleBetaEnvironmentsCreate(ctx context.Context, cmd *cli.Command) error {
253253
return ShowJSON(obj, ShowJSONOpts{
254254
ExplicitFormat: explicitFormat,
255255
Format: format,
256+
RawOutput: cmd.Root().Bool("raw-output"),
256257
Title: "beta:environments create",
257258
Transform: transform,
258259
})
@@ -301,6 +302,7 @@ func handleBetaEnvironmentsRetrieve(ctx context.Context, cmd *cli.Command) error
301302
return ShowJSON(obj, ShowJSONOpts{
302303
ExplicitFormat: explicitFormat,
303304
Format: format,
305+
RawOutput: cmd.Root().Bool("raw-output"),
304306
Title: "beta:environments retrieve",
305307
Transform: transform,
306308
})
@@ -349,6 +351,7 @@ func handleBetaEnvironmentsUpdate(ctx context.Context, cmd *cli.Command) error {
349351
return ShowJSON(obj, ShowJSONOpts{
350352
ExplicitFormat: explicitFormat,
351353
Format: format,
354+
RawOutput: cmd.Root().Bool("raw-output"),
352355
Title: "beta:environments update",
353356
Transform: transform,
354357
})
@@ -389,6 +392,7 @@ func handleBetaEnvironmentsList(ctx context.Context, cmd *cli.Command) error {
389392
return ShowJSON(obj, ShowJSONOpts{
390393
ExplicitFormat: explicitFormat,
391394
Format: format,
395+
RawOutput: cmd.Root().Bool("raw-output"),
392396
Title: "beta:environments list",
393397
Transform: transform,
394398
})
@@ -401,6 +405,7 @@ func handleBetaEnvironmentsList(ctx context.Context, cmd *cli.Command) error {
401405
return ShowJSONIterator(iter, maxItems, ShowJSONOpts{
402406
ExplicitFormat: explicitFormat,
403407
Format: format,
408+
RawOutput: cmd.Root().Bool("raw-output"),
404409
Title: "beta:environments list",
405410
Transform: transform,
406411
})
@@ -450,6 +455,7 @@ func handleBetaEnvironmentsDelete(ctx context.Context, cmd *cli.Command) error {
450455
return ShowJSON(obj, ShowJSONOpts{
451456
ExplicitFormat: explicitFormat,
452457
Format: format,
458+
RawOutput: cmd.Root().Bool("raw-output"),
453459
Title: "beta:environments delete",
454460
Transform: transform,
455461
})
@@ -498,6 +504,7 @@ func handleBetaEnvironmentsArchive(ctx context.Context, cmd *cli.Command) error
498504
return ShowJSON(obj, ShowJSONOpts{
499505
ExplicitFormat: explicitFormat,
500506
Format: format,
507+
RawOutput: cmd.Root().Bool("raw-output"),
501508
Title: "beta:environments archive",
502509
Transform: transform,
503510
})

pkg/cmd/betafile.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ func handleBetaFilesList(ctx context.Context, cmd *cli.Command) error {
177177
return ShowJSON(obj, ShowJSONOpts{
178178
ExplicitFormat: explicitFormat,
179179
Format: format,
180+
RawOutput: cmd.Root().Bool("raw-output"),
180181
Title: "beta:files list",
181182
Transform: transform,
182183
})
@@ -192,6 +193,7 @@ func handleBetaFilesList(ctx context.Context, cmd *cli.Command) error {
192193
return ShowJSONIterator(iter, maxItems, ShowJSONOpts{
193194
ExplicitFormat: explicitFormat,
194195
Format: format,
196+
RawOutput: cmd.Root().Bool("raw-output"),
195197
Title: "beta:files list",
196198
Transform: transform,
197199
})
@@ -241,6 +243,7 @@ func handleBetaFilesDelete(ctx context.Context, cmd *cli.Command) error {
241243
return ShowJSON(obj, ShowJSONOpts{
242244
ExplicitFormat: explicitFormat,
243245
Format: format,
246+
RawOutput: cmd.Root().Bool("raw-output"),
244247
Title: "beta:files delete",
245248
Transform: transform,
246249
})
@@ -329,6 +332,7 @@ func handleBetaFilesRetrieveMetadata(ctx context.Context, cmd *cli.Command) erro
329332
return ShowJSON(obj, ShowJSONOpts{
330333
ExplicitFormat: explicitFormat,
331334
Format: format,
335+
RawOutput: cmd.Root().Bool("raw-output"),
332336
Title: "beta:files retrieve-metadata",
333337
Transform: transform,
334338
})
@@ -369,6 +373,7 @@ func handleBetaFilesUpload(ctx context.Context, cmd *cli.Command) error {
369373
return ShowJSON(obj, ShowJSONOpts{
370374
ExplicitFormat: explicitFormat,
371375
Format: format,
376+
RawOutput: cmd.Root().Bool("raw-output"),
372377
Title: "beta:files upload",
373378
Transform: transform,
374379
})

pkg/cmd/betamessage.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ func handleBetaMessagesCreate(ctx context.Context, cmd *cli.Command) error {
423423
return ShowJSONIterator(stream, maxItems, ShowJSONOpts{
424424
ExplicitFormat: explicitFormat,
425425
Format: format,
426+
RawOutput: cmd.Root().Bool("raw-output"),
426427
Title: "beta:messages create",
427428
Transform: transform,
428429
})
@@ -438,6 +439,7 @@ func handleBetaMessagesCreate(ctx context.Context, cmd *cli.Command) error {
438439
return ShowJSON(obj, ShowJSONOpts{
439440
ExplicitFormat: explicitFormat,
440441
Format: format,
442+
RawOutput: cmd.Root().Bool("raw-output"),
441443
Title: "beta:messages create",
442444
Transform: transform,
443445
})
@@ -479,6 +481,7 @@ func handleBetaMessagesCountTokens(ctx context.Context, cmd *cli.Command) error
479481
return ShowJSON(obj, ShowJSONOpts{
480482
ExplicitFormat: explicitFormat,
481483
Format: format,
484+
RawOutput: cmd.Root().Bool("raw-output"),
482485
Title: "beta:messages count-tokens",
483486
Transform: transform,
484487
})

pkg/cmd/betamessagebatch.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ func handleBetaMessagesBatchesCreate(ctx context.Context, cmd *cli.Command) erro
202202
return ShowJSON(obj, ShowJSONOpts{
203203
ExplicitFormat: explicitFormat,
204204
Format: format,
205+
RawOutput: cmd.Root().Bool("raw-output"),
205206
Title: "beta:messages:batches create",
206207
Transform: transform,
207208
})
@@ -250,6 +251,7 @@ func handleBetaMessagesBatchesRetrieve(ctx context.Context, cmd *cli.Command) er
250251
return ShowJSON(obj, ShowJSONOpts{
251252
ExplicitFormat: explicitFormat,
252253
Format: format,
254+
RawOutput: cmd.Root().Bool("raw-output"),
253255
Title: "beta:messages:batches retrieve",
254256
Transform: transform,
255257
})
@@ -290,6 +292,7 @@ func handleBetaMessagesBatchesList(ctx context.Context, cmd *cli.Command) error
290292
return ShowJSON(obj, ShowJSONOpts{
291293
ExplicitFormat: explicitFormat,
292294
Format: format,
295+
RawOutput: cmd.Root().Bool("raw-output"),
293296
Title: "beta:messages:batches list",
294297
Transform: transform,
295298
})
@@ -305,6 +308,7 @@ func handleBetaMessagesBatchesList(ctx context.Context, cmd *cli.Command) error
305308
return ShowJSONIterator(iter, maxItems, ShowJSONOpts{
306309
ExplicitFormat: explicitFormat,
307310
Format: format,
311+
RawOutput: cmd.Root().Bool("raw-output"),
308312
Title: "beta:messages:batches list",
309313
Transform: transform,
310314
})
@@ -354,6 +358,7 @@ func handleBetaMessagesBatchesDelete(ctx context.Context, cmd *cli.Command) erro
354358
return ShowJSON(obj, ShowJSONOpts{
355359
ExplicitFormat: explicitFormat,
356360
Format: format,
361+
RawOutput: cmd.Root().Bool("raw-output"),
357362
Title: "beta:messages:batches delete",
358363
Transform: transform,
359364
})
@@ -402,6 +407,7 @@ func handleBetaMessagesBatchesCancel(ctx context.Context, cmd *cli.Command) erro
402407
return ShowJSON(obj, ShowJSONOpts{
403408
ExplicitFormat: explicitFormat,
404409
Format: format,
410+
RawOutput: cmd.Root().Bool("raw-output"),
405411
Title: "beta:messages:batches cancel",
406412
Transform: transform,
407413
})
@@ -447,6 +453,7 @@ func handleBetaMessagesBatchesResults(ctx context.Context, cmd *cli.Command) err
447453
return ShowJSONIterator(stream, maxItems, ShowJSONOpts{
448454
ExplicitFormat: explicitFormat,
449455
Format: format,
456+
RawOutput: cmd.Root().Bool("raw-output"),
450457
Title: "beta:messages:batches results",
451458
Transform: transform,
452459
})

pkg/cmd/betamodel.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ func handleBetaModelsRetrieve(ctx context.Context, cmd *cli.Command) error {
112112
return ShowJSON(obj, ShowJSONOpts{
113113
ExplicitFormat: explicitFormat,
114114
Format: format,
115+
RawOutput: cmd.Root().Bool("raw-output"),
115116
Title: "beta:models retrieve",
116117
Transform: transform,
117118
})
@@ -152,6 +153,7 @@ func handleBetaModelsList(ctx context.Context, cmd *cli.Command) error {
152153
return ShowJSON(obj, ShowJSONOpts{
153154
ExplicitFormat: explicitFormat,
154155
Format: format,
156+
RawOutput: cmd.Root().Bool("raw-output"),
155157
Title: "beta:models list",
156158
Transform: transform,
157159
})
@@ -167,6 +169,7 @@ func handleBetaModelsList(ctx context.Context, cmd *cli.Command) error {
167169
return ShowJSONIterator(iter, maxItems, ShowJSONOpts{
168170
ExplicitFormat: explicitFormat,
169171
Format: format,
172+
RawOutput: cmd.Root().Bool("raw-output"),
170173
Title: "beta:models list",
171174
Transform: transform,
172175
})

pkg/cmd/betasession.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ func handleBetaSessionsCreate(ctx context.Context, cmd *cli.Command) error {
256256
return ShowJSON(obj, ShowJSONOpts{
257257
ExplicitFormat: explicitFormat,
258258
Format: format,
259+
RawOutput: cmd.Root().Bool("raw-output"),
259260
Title: "beta:sessions create",
260261
Transform: transform,
261262
})
@@ -304,6 +305,7 @@ func handleBetaSessionsRetrieve(ctx context.Context, cmd *cli.Command) error {
304305
return ShowJSON(obj, ShowJSONOpts{
305306
ExplicitFormat: explicitFormat,
306307
Format: format,
308+
RawOutput: cmd.Root().Bool("raw-output"),
307309
Title: "beta:sessions retrieve",
308310
Transform: transform,
309311
})
@@ -352,6 +354,7 @@ func handleBetaSessionsUpdate(ctx context.Context, cmd *cli.Command) error {
352354
return ShowJSON(obj, ShowJSONOpts{
353355
ExplicitFormat: explicitFormat,
354356
Format: format,
357+
RawOutput: cmd.Root().Bool("raw-output"),
355358
Title: "beta:sessions update",
356359
Transform: transform,
357360
})
@@ -392,6 +395,7 @@ func handleBetaSessionsList(ctx context.Context, cmd *cli.Command) error {
392395
return ShowJSON(obj, ShowJSONOpts{
393396
ExplicitFormat: explicitFormat,
394397
Format: format,
398+
RawOutput: cmd.Root().Bool("raw-output"),
395399
Title: "beta:sessions list",
396400
Transform: transform,
397401
})
@@ -404,6 +408,7 @@ func handleBetaSessionsList(ctx context.Context, cmd *cli.Command) error {
404408
return ShowJSONIterator(iter, maxItems, ShowJSONOpts{
405409
ExplicitFormat: explicitFormat,
406410
Format: format,
411+
RawOutput: cmd.Root().Bool("raw-output"),
407412
Title: "beta:sessions list",
408413
Transform: transform,
409414
})
@@ -453,6 +458,7 @@ func handleBetaSessionsDelete(ctx context.Context, cmd *cli.Command) error {
453458
return ShowJSON(obj, ShowJSONOpts{
454459
ExplicitFormat: explicitFormat,
455460
Format: format,
461+
RawOutput: cmd.Root().Bool("raw-output"),
456462
Title: "beta:sessions delete",
457463
Transform: transform,
458464
})
@@ -501,6 +507,7 @@ func handleBetaSessionsArchive(ctx context.Context, cmd *cli.Command) error {
501507
return ShowJSON(obj, ShowJSONOpts{
502508
ExplicitFormat: explicitFormat,
503509
Format: format,
510+
RawOutput: cmd.Root().Bool("raw-output"),
504511
Title: "beta:sessions archive",
505512
Transform: transform,
506513
})

pkg/cmd/betasessionevent.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ func handleBetaSessionsEventsList(ctx context.Context, cmd *cli.Command) error {
143143
return ShowJSON(obj, ShowJSONOpts{
144144
ExplicitFormat: explicitFormat,
145145
Format: format,
146+
RawOutput: cmd.Root().Bool("raw-output"),
146147
Title: "beta:sessions:events list",
147148
Transform: transform,
148149
})
@@ -160,6 +161,7 @@ func handleBetaSessionsEventsList(ctx context.Context, cmd *cli.Command) error {
160161
return ShowJSONIterator(iter, maxItems, ShowJSONOpts{
161162
ExplicitFormat: explicitFormat,
162163
Format: format,
164+
RawOutput: cmd.Root().Bool("raw-output"),
163165
Title: "beta:sessions:events list",
164166
Transform: transform,
165167
})
@@ -209,6 +211,7 @@ func handleBetaSessionsEventsSend(ctx context.Context, cmd *cli.Command) error {
209211
return ShowJSON(obj, ShowJSONOpts{
210212
ExplicitFormat: explicitFormat,
211213
Format: format,
214+
RawOutput: cmd.Root().Bool("raw-output"),
212215
Title: "beta:sessions:events send",
213216
Transform: transform,
214217
})
@@ -254,6 +257,7 @@ func handleBetaSessionsEventsStream(ctx context.Context, cmd *cli.Command) error
254257
return ShowJSONIterator(stream, maxItems, ShowJSONOpts{
255258
ExplicitFormat: explicitFormat,
256259
Format: format,
260+
RawOutput: cmd.Root().Bool("raw-output"),
257261
Title: "beta:sessions:events stream",
258262
Transform: transform,
259263
})

pkg/cmd/betasessionresource.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ func handleBetaSessionsResourcesRetrieve(ctx context.Context, cmd *cli.Command)
203203
return ShowJSON(obj, ShowJSONOpts{
204204
ExplicitFormat: explicitFormat,
205205
Format: format,
206+
RawOutput: cmd.Root().Bool("raw-output"),
206207
Title: "beta:sessions:resources retrieve",
207208
Transform: transform,
208209
})
@@ -253,6 +254,7 @@ func handleBetaSessionsResourcesUpdate(ctx context.Context, cmd *cli.Command) er
253254
return ShowJSON(obj, ShowJSONOpts{
254255
ExplicitFormat: explicitFormat,
255256
Format: format,
257+
RawOutput: cmd.Root().Bool("raw-output"),
256258
Title: "beta:sessions:resources update",
257259
Transform: transform,
258260
})
@@ -301,6 +303,7 @@ func handleBetaSessionsResourcesList(ctx context.Context, cmd *cli.Command) erro
301303
return ShowJSON(obj, ShowJSONOpts{
302304
ExplicitFormat: explicitFormat,
303305
Format: format,
306+
RawOutput: cmd.Root().Bool("raw-output"),
304307
Title: "beta:sessions:resources list",
305308
Transform: transform,
306309
})
@@ -318,6 +321,7 @@ func handleBetaSessionsResourcesList(ctx context.Context, cmd *cli.Command) erro
318321
return ShowJSONIterator(iter, maxItems, ShowJSONOpts{
319322
ExplicitFormat: explicitFormat,
320323
Format: format,
324+
RawOutput: cmd.Root().Bool("raw-output"),
321325
Title: "beta:sessions:resources list",
322326
Transform: transform,
323327
})
@@ -369,6 +373,7 @@ func handleBetaSessionsResourcesDelete(ctx context.Context, cmd *cli.Command) er
369373
return ShowJSON(obj, ShowJSONOpts{
370374
ExplicitFormat: explicitFormat,
371375
Format: format,
376+
RawOutput: cmd.Root().Bool("raw-output"),
372377
Title: "beta:sessions:resources delete",
373378
Transform: transform,
374379
})
@@ -417,6 +422,7 @@ func handleBetaSessionsResourcesAdd(ctx context.Context, cmd *cli.Command) error
417422
return ShowJSON(obj, ShowJSONOpts{
418423
ExplicitFormat: explicitFormat,
419424
Format: format,
425+
RawOutput: cmd.Root().Bool("raw-output"),
420426
Title: "beta:sessions:resources add",
421427
Transform: transform,
422428
})

0 commit comments

Comments
 (0)