Skip to content

Commit 2bceaa2

Browse files
committed
cp dines
1 parent 0362aad commit 2bceaa2

7 files changed

Lines changed: 1006 additions & 71 deletions

File tree

src/cli.ts

Lines changed: 63 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,15 @@ program
4646
const devbox = program
4747
.command("devbox")
4848
.description("Manage devboxes")
49-
.alias("d");
49+
.alias("d")
50+
.action(async () => {
51+
// Open interactive devbox list when no subcommand provided
52+
const { runInteractiveCommand } = await import(
53+
"./utils/interactiveCommand.js"
54+
);
55+
const { listDevboxes } = await import("./commands/devbox/list.js");
56+
await runInteractiveCommand(() => listDevboxes({ output: "interactive" }));
57+
});
5058

5159
devbox
5260
.command("create")
@@ -65,7 +73,7 @@ devbox
6573
.option("--user <user:uid>", "Run as this user (format: username:uid)")
6674
.option(
6775
"-o, --output [format]",
68-
"Output format: text|json|yaml (default: interactive)",
76+
"Output format: text|json|yaml (default: text)",
6977
)
7078
.action(createDevbox);
7179

@@ -75,18 +83,10 @@ devbox
7583
.option("-s, --status <status>", "Filter by status")
7684
.option(
7785
"-o, --output [format]",
78-
"Output format: text|json|yaml (default: interactive)",
86+
"Output format: text|json|yaml (default: json)",
7987
)
8088
.action(async (options) => {
81-
// Only use alternate screen for interactive mode
82-
if (!options.output) {
83-
const { runInteractiveCommand } = await import(
84-
"./utils/interactiveCommand.js"
85-
);
86-
await runInteractiveCommand(() => listDevboxes(options));
87-
} else {
88-
await listDevboxes(options);
89-
}
89+
await listDevboxes(options);
9090
});
9191

9292
devbox
@@ -95,7 +95,7 @@ devbox
9595
.alias("rm")
9696
.option(
9797
"-o, --output [format]",
98-
"Output format: text|json|yaml (default: interactive)",
98+
"Output format: text|json|yaml (default: text)",
9999
)
100100
.action(deleteDevbox);
101101

@@ -104,7 +104,7 @@ devbox
104104
.description("Execute a command in a devbox")
105105
.option(
106106
"-o, --output [format]",
107-
"Output format: text|json|yaml (default: interactive)",
107+
"Output format: text|json|yaml (default: text)",
108108
)
109109
.action(async (id, command, options) => {
110110
await execCommand(id, command, options);
@@ -116,7 +116,7 @@ devbox
116116
.option("-p, --path <path>", "Target path in devbox")
117117
.option(
118118
"-o, --output [format]",
119-
"Output format: text|json|yaml (default: interactive)",
119+
"Output format: text|json|yaml (default: text)",
120120
)
121121
.action(uploadFile);
122122

@@ -126,7 +126,7 @@ devbox
126126
.description("Get devbox details")
127127
.option(
128128
"-o, --output [format]",
129-
"Output format: text|json|yaml (default: interactive)",
129+
"Output format: text|json|yaml (default: json)",
130130
)
131131
.action(async (id, options) => {
132132
const { getDevbox } = await import("./commands/devbox/get.js");
@@ -138,7 +138,7 @@ devbox
138138
.description("Suspend a devbox")
139139
.option(
140140
"-o, --output [format]",
141-
"Output format: text|json|yaml (default: interactive)",
141+
"Output format: text|json|yaml (default: text)",
142142
)
143143
.action(async (id, options) => {
144144
const { suspendDevbox } = await import("./commands/devbox/suspend.js");
@@ -150,7 +150,7 @@ devbox
150150
.description("Resume a suspended devbox")
151151
.option(
152152
"-o, --output [format]",
153-
"Output format: text|json|yaml (default: interactive)",
153+
"Output format: text|json|yaml (default: text)",
154154
)
155155
.action(async (id, options) => {
156156
const { resumeDevbox } = await import("./commands/devbox/resume.js");
@@ -162,7 +162,7 @@ devbox
162162
.description("Shutdown a devbox")
163163
.option(
164164
"-o, --output [format]",
165-
"Output format: text|json|yaml (default: interactive)",
165+
"Output format: text|json|yaml (default: text)",
166166
)
167167
.action(async (id, options) => {
168168
const { shutdownDevbox } = await import("./commands/devbox/shutdown.js");
@@ -186,7 +186,7 @@ devbox
186186
)
187187
.option(
188188
"-o, --output [format]",
189-
"Output format: text|json|yaml (default: interactive)",
189+
"Output format: text|json|yaml (default: text)",
190190
)
191191
.action(async (id, options) => {
192192
const { sshDevbox } = await import("./commands/devbox/ssh.js");
@@ -199,7 +199,7 @@ devbox
199199
.option("--scp-options <options>", "Additional scp options (quoted)")
200200
.option(
201201
"-o, --output [format]",
202-
"Output format: text|json|yaml (default: interactive)",
202+
"Output format: text|json|yaml (default: text)",
203203
)
204204
.action(async (id, src, dst, options) => {
205205
const { scpFiles } = await import("./commands/devbox/scp.js");
@@ -212,7 +212,7 @@ devbox
212212
.option("--rsync-options <options>", "Additional rsync options (quoted)")
213213
.option(
214214
"-o, --output [format]",
215-
"Output format: text|json|yaml (default: interactive)",
215+
"Output format: text|json|yaml (default: text)",
216216
)
217217
.action(async (id, src, dst, options) => {
218218
const { rsyncFiles } = await import("./commands/devbox/rsync.js");
@@ -224,7 +224,7 @@ devbox
224224
.description("Create a port-forwarding tunnel to a devbox")
225225
.option(
226226
"-o, --output [format]",
227-
"Output format: text|json|yaml (default: interactive)",
227+
"Output format: text|json|yaml (default: text)",
228228
)
229229
.action(async (id, ports, options) => {
230230
const { createTunnel } = await import("./commands/devbox/tunnel.js");
@@ -238,7 +238,7 @@ devbox
238238
.option("--output-path <path>", "Local file path to write the contents to")
239239
.option(
240240
"-o, --output [format]",
241-
"Output format: text|json|yaml (default: interactive)",
241+
"Output format: text|json|yaml (default: text)",
242242
)
243243
.action(async (id, options) => {
244244
const { readFile } = await import("./commands/devbox/read.js");
@@ -252,7 +252,7 @@ devbox
252252
.option("--remote <path>", "Remote file path to write to on the devbox")
253253
.option(
254254
"-o, --output [format]",
255-
"Output format: text|json|yaml (default: interactive)",
255+
"Output format: text|json|yaml (default: text)",
256256
)
257257
.action(async (id, options) => {
258258
const { writeFile } = await import("./commands/devbox/write.js");
@@ -282,7 +282,7 @@ devbox
282282
.option("--shell-name <name>", "Shell name to use (optional)")
283283
.option(
284284
"-o, --output [format]",
285-
"Output format: text|json|yaml (default: interactive)",
285+
"Output format: text|json|yaml (default: text)",
286286
)
287287
.action(async (id, command, options) => {
288288
const { execAsync } = await import("./commands/devbox/execAsync.js");
@@ -294,7 +294,7 @@ devbox
294294
.description("Get status of an async execution")
295295
.option(
296296
"-o, --output [format]",
297-
"Output format: text|json|yaml (default: interactive)",
297+
"Output format: text|json|yaml (default: text)",
298298
)
299299
.action(async (id, executionId, options) => {
300300
const { getAsync } = await import("./commands/devbox/getAsync.js");
@@ -306,7 +306,7 @@ devbox
306306
.description("View devbox logs")
307307
.option(
308308
"-o, --output [format]",
309-
"Output format: text|json|yaml (default: interactive)",
309+
"Output format: text|json|yaml (default: text)",
310310
)
311311
.action(async (id, options) => {
312312
const { getLogs } = await import("./commands/devbox/logs.js");
@@ -317,26 +317,27 @@ devbox
317317
const snapshot = program
318318
.command("snapshot")
319319
.description("Manage devbox snapshots")
320-
.alias("snap");
320+
.alias("snap")
321+
.action(async () => {
322+
// Open interactive snapshot list when no subcommand provided
323+
const { runInteractiveCommand } = await import(
324+
"./utils/interactiveCommand.js"
325+
);
326+
const { listSnapshots } = await import("./commands/snapshot/list.js");
327+
await runInteractiveCommand(() => listSnapshots({ output: "interactive" }));
328+
});
321329

322330
snapshot
323331
.command("list")
324332
.description("List all snapshots")
325333
.option("-d, --devbox <id>", "Filter by devbox ID")
326334
.option(
327335
"-o, --output [format]",
328-
"Output format: text|json|yaml (default: interactive)",
336+
"Output format: text|json|yaml (default: json)",
329337
)
330338
.action(async (options) => {
331339
const { listSnapshots } = await import("./commands/snapshot/list.js");
332-
if (!options.output) {
333-
const { runInteractiveCommand } = await import(
334-
"./utils/interactiveCommand.js"
335-
);
336-
await runInteractiveCommand(() => listSnapshots(options));
337-
} else {
338-
await listSnapshots(options);
339-
}
340+
await listSnapshots(options);
340341
});
341342

342343
snapshot
@@ -345,7 +346,7 @@ snapshot
345346
.option("-n, --name <name>", "Snapshot name")
346347
.option(
347348
"-o, --output [format]",
348-
"Output format: text|json|yaml (default: interactive)",
349+
"Output format: text|json|yaml (default: text)",
349350
)
350351
.action(async (devboxId, options) => {
351352
const { createSnapshot } = await import("./commands/snapshot/create.js");
@@ -358,7 +359,7 @@ snapshot
358359
.alias("rm")
359360
.option(
360361
"-o, --output [format]",
361-
"Output format: text|json|yaml (default: interactive)",
362+
"Output format: text|json|yaml (default: text)",
362363
)
363364
.action(async (id, options) => {
364365
const { deleteSnapshot } = await import("./commands/snapshot/delete.js");
@@ -370,7 +371,7 @@ snapshot
370371
.description("Get snapshot operation status")
371372
.option(
372373
"-o, --output [format]",
373-
"Output format: text|json|yaml (default: interactive)",
374+
"Output format: text|json|yaml (default: text)",
374375
)
375376
.action(async (snapshotId, options) => {
376377
const { getSnapshotStatus } = await import("./commands/snapshot/status.js");
@@ -381,25 +382,26 @@ snapshot
381382
const blueprint = program
382383
.command("blueprint")
383384
.description("Manage blueprints")
384-
.alias("bp");
385+
.alias("bp")
386+
.action(async () => {
387+
// Open interactive blueprint list when no subcommand provided
388+
const { runInteractiveCommand } = await import(
389+
"./utils/interactiveCommand.js"
390+
);
391+
const { listBlueprints } = await import("./commands/blueprint/list.js");
392+
await runInteractiveCommand(() => listBlueprints({ output: "interactive" }));
393+
});
385394

386395
blueprint
387396
.command("list")
388397
.description("List all blueprints")
389398
.option(
390399
"-o, --output [format]",
391-
"Output format: text|json|yaml (default: interactive)",
400+
"Output format: text|json|yaml (default: json)",
392401
)
393402
.action(async (options) => {
394403
const { listBlueprints } = await import("./commands/blueprint/list.js");
395-
if (!options.output) {
396-
const { runInteractiveCommand } = await import(
397-
"./utils/interactiveCommand.js"
398-
);
399-
await runInteractiveCommand(() => listBlueprints(options));
400-
} else {
401-
await listBlueprints(options);
402-
}
404+
await listBlueprints(options);
403405
});
404406

405407
blueprint
@@ -418,7 +420,7 @@ blueprint
418420
.option("--user <user:uid>", "Run as this user (format: username:uid)")
419421
.option(
420422
"-o, --output [format]",
421-
"Output format: text|json|yaml (default: interactive)",
423+
"Output format: text|json|yaml (default: text)",
422424
)
423425
.action(async (name, options) => {
424426
const { createBlueprint } = await import("./commands/blueprint/create.js");
@@ -440,7 +442,7 @@ blueprint
440442
.option("--user <user:uid>", "Run as this user (format: username:uid)")
441443
.option(
442444
"-o, --output [format]",
443-
"Output format: text|json|yaml (default: interactive)",
445+
"Output format: text|json|yaml (default: text)",
444446
)
445447
.action(async (name, options) => {
446448
const { previewBlueprint } = await import(
@@ -454,7 +456,7 @@ blueprint
454456
.description("Get blueprint details")
455457
.option(
456458
"-o, --output [format]",
457-
"Output format: text|json|yaml (default: interactive)",
459+
"Output format: text|json|yaml (default: text)",
458460
)
459461
.action(async (id, options) => {
460462
const { getBlueprint } = await import("./commands/blueprint/get.js");
@@ -466,7 +468,7 @@ blueprint
466468
.description("Get blueprint build logs")
467469
.option(
468470
"-o, --output [format]",
469-
"Output format: text|json|yaml (default: interactive)",
471+
"Output format: text|json|yaml (default: text)",
470472
)
471473
.action(async (id, options) => {
472474
const { getBlueprintLogs } = await import("./commands/blueprint/logs.js");
@@ -491,26 +493,19 @@ object
491493
.option("--public", "List public objects only")
492494
.option(
493495
"-o, --output [format]",
494-
"Output format: text|json|yaml (default: interactive)",
496+
"Output format: text|json|yaml (default: json)",
495497
)
496498
.action(async (options) => {
497499
const { listObjects } = await import("./commands/object/list.js");
498-
if (!options.output) {
499-
const { runInteractiveCommand } = await import(
500-
"./utils/interactiveCommand.js"
501-
);
502-
await runInteractiveCommand(() => listObjects(options));
503-
} else {
504-
await listObjects(options);
505-
}
500+
await listObjects(options);
506501
});
507502

508503
object
509504
.command("get <id>")
510505
.description("Get object details")
511506
.option(
512507
"-o, --output [format]",
513-
"Output format: text|json|yaml (default: interactive)",
508+
"Output format: text|json|yaml (default: text)",
514509
)
515510
.action(async (id, options) => {
516511
const { getObject } = await import("./commands/object/get.js");
@@ -528,7 +523,7 @@ object
528523
)
529524
.option(
530525
"-o, --output [format]",
531-
"Output format: text|json|yaml (default: interactive)",
526+
"Output format: text|json|yaml (default: text)",
532527
)
533528
.action(async (id, path, options) => {
534529
const { downloadObject } = await import("./commands/object/download.js");
@@ -546,7 +541,7 @@ object
546541
.option("--public", "Make object publicly accessible")
547542
.option(
548543
"-o, --output [format]",
549-
"Output format: text|json|yaml (default: interactive)",
544+
"Output format: text|json|yaml (default: text)",
550545
)
551546
.action(async (path, options) => {
552547
const { uploadObject } = await import("./commands/object/upload.js");
@@ -565,7 +560,7 @@ object
565560
.description("Delete an object (irreversible)")
566561
.option(
567562
"-o, --output [format]",
568-
"Output format: text|json|yaml (default: interactive)",
563+
"Output format: text|json|yaml (default: text)",
569564
)
570565
.action(async (id, options) => {
571566
const { deleteObject } = await import("./commands/object/delete.js");

0 commit comments

Comments
 (0)