Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

CLI: format table > pretty to match rest of DX, added docs (#905)

Mish Ushakovc6efe1f26c51
diff --git a/.changeset/strong-turtles-shake.md b/.changeset/strong-turtles-shake.md
new file mode 100644
index 000000000..894cc8071
--- /dev/null
+++ b/.changeset/strong-turtles-shake.md
@@ -0,0 +1,5 @@
+---
+'@e2b/cli': minor
+---
+
+changed table format option to pretty, added docs
diff --git a/apps/web/src/app/(docs)/docs/cli/list-sandboxes/page.mdx b/apps/web/src/app/(docs)/docs/cli/list-sandboxes/page.mdx
index 6d9b55317..4ff5f2fed 100644
--- a/apps/web/src/app/(docs)/docs/cli/list-sandboxes/page.mdx
+++ b/apps/web/src/app/(docs)/docs/cli/list-sandboxes/page.mdx
@@ -34,4 +34,20 @@ To limit the amount of sandboxes returned by the command, use the `--limit` flag
e2b sandbox list --limit 10
```
-By default, the command will return all sandboxes.
\ No newline at end of file
+By default, the command will return all sandboxes.
+
+### Output format
+
+To output the sandboxes in JSON format, use the `--format` flag.
+
+**Pretty print (default)**
+
+```bash
+e2b sandbox list --format pretty
+```
+
+**JSON**
+
+```bash
+e2b sandbox list --format json
+```
diff --git a/packages/cli/src/commands/sandbox/list.ts b/packages/cli/src/commands/sandbox/list.ts
index 2861fb12e..1e9c47419 100644
--- a/packages/cli/src/commands/sandbox/list.ts
+++ b/packages/cli/src/commands/sandbox/list.ts
@@ -27,18 +27,18 @@ export const listCommand = new commander.Command('list')
'limit the number of sandboxes returned',
(value) => parseInt(value)
)
- .option('-f, --format <format>', 'output format, eg. json, table')
+ .option('-f, --format <format>', 'output format, eg. json, pretty')
.action(async (options) => {
try {
const state = options.state || ['running']
- const format = options.format || 'table'
+ const format = options.format || 'pretty'
const sandboxes = await listSandboxes({
limit: options.limit,
state,
metadataRaw: options.metadata,
})
- if (format === 'table') {
+ if (format === 'pretty') {
renderTable(sandboxes, state)
} else if (format === 'json') {
console.log(JSON.stringify(sandboxes, null, 2))
diff --git a/packages/cli/src/commands/template/list.ts b/packages/cli/src/commands/template/list.ts
index d41acd2ec..8de09fb4d 100644
--- a/packages/cli/src/commands/template/list.ts
+++ b/packages/cli/src/commands/template/list.ts
@@ -13,10 +13,10 @@ export const listCommand = new commander.Command('list')
.description('list sandbox templates')
.alias('ls')
.addOption(teamOption)
- .option('-f, --format <format>', 'output format, eg. json, table')
+ .option('-f, --format <format>', 'output format, eg. json, pretty')
.action(async (opts: { team: string; format: string }) => {
try {
- const format = opts.format || 'table'
+ const format = opts.format || 'pretty'
const userConfig = getUserConfig()
ensureAccessToken()
process.stdout.write('\n')
@@ -29,7 +29,7 @@ export const listCommand = new commander.Command('list')
sortTemplatesAliases(template.aliases)
}
- if (format === 'table') {
+ if (format === 'pretty') {
renderTable(templates)
} else if (format === 'json') {
console.log(JSON.stringify(templates, null, 2))