Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Add CLI section to docs

Jakub Novakd03657539be3
diff --git a/apps/docs/src/app/cli/commands/page.mdx b/apps/docs/src/app/cli/commands/page.mdx
new file mode 100644
index 000000000..bcf272861
--- /dev/null
+++ b/apps/docs/src/app/cli/commands/page.mdx
@@ -0,0 +1,117 @@
+# CLI Commands
+
+Build your own sandbox with our CLI. {{ className: 'lead' }}
+
+## init
+
+Create basic E2B Dockerfile (`./e2b.Dockerfile`) in current directory. You can then run `e2b build` to build sandbox template from this Dockerfile
+
+```bash
+e2b template init
+```
+
+### Options:
+
+<Properties>
+ <Property name="path" type="-p --path">
+ Change root directory where command is executed to `path` directory
+ </Property>
+</Properties>
+
+---
+
+## login
+
+Log in to CLI. It will save your access token in `~/.e2b` file.
+
+```bash
+e2b login
+```
+
+---
+
+## logout
+
+Log out from CLI. It will remove your accesstoken from `~/.e2b` file.
+
+```bash
+e2b logout
+```
+
+---
+
+## build
+
+Build sandbox template defined by `./e2b.Dockerfile` or `./Dockerfile` in root directory. By default the root directory is the current working directory. This command also creates `e2b.toml` config.
+
+```bash
+e2b build
+```
+
+### Options:
+
+<Properties>
+ <Property name="name" type="-n --name">
+ Specify name of sandbox template. You can use the name to start the sandbox in the SDK. The name must be lowercase and contain only letters, numbers, dashes and underscores.
+ </Property>
+ <Property name="path" type="-p --path">
+ Change root directory where command is executed to `path` directory
+ </Property>
+ <Property name="dockerfile" type="-d --dockerfile">
+ Specify path to Dockerfile. By default E2B tries to find `e2b.Dockerfile` or `Dockerfile` in root directory
+ </Property>
+</Properties>
+
+---
+
+## list
+
+List your sandbox templates
+
+```bash
+e2b list
+```
+
+---
+
+## shell
+
+Connect terminal to sandbox. This command can be used to debug your sandbox template. It works as `docker run -it <image> bash` command.
+
+```bash
+e2b shell
+```
+
+### Options:
+
+<Properties>
+ <Property name="path" type="-p --path">
+ Change root directory where command is executed to `path` directory
+ </Property>
+</Properties>
+
+---
+
+## help
+
+Show help
+
+```bash
+e2b help
+```
+
+---
+
+## version
+
+Show version of the CLI
+
+```bash
+e2b version
+```
+
+## Next steps
+
+1. [Create your first sandbox template](/sandbox/templates/overview)
+1. [Check out the official guides](/guides/custom-sandbox)
+{/* 1. [Follow the "Hello World" example](/guides/) */}
diff --git a/apps/docs/src/app/cli/installation/page.mdx b/apps/docs/src/app/cli/installation/page.mdx
new file mode 100644
index 000000000..52f25f130
--- /dev/null
+++ b/apps/docs/src/app/cli/installation/page.mdx
@@ -0,0 +1,30 @@
+# Installation
+
+You build and manage your sandbox templates with our CLI. {{ className: 'lead' }}
+
+The CLI is distributed as an [NPM package](https://www.npmjs.com/package/@e2b/sdk).
+
+## Download CLI
+
+You can install them using the following commands:
+
+```bash
+npm i -g @e2b/cli
+```
+
+
+## Login
+
+You'll need to login to your account to use the CLI. It'll redirect you to the browser to authenticate.
+
+```bash
+e2b login
+```
+
+
+## Next steps
+
+1. [Create your first sandbox template](/sandbox/templates/overview)
+1. [Explore the CLI API](/CLI/commnads)
+1. [Check out the official guides](/guides/custom-sandbox)
+{/* 1. [Follow the "Hello World" example](/guides/) */}
diff --git a/apps/docs/src/components/Navigation/routes.tsx b/apps/docs/src/components/Navigation/routes.tsx
index 7ced79c28..90fd3c329 100644
--- a/apps/docs/src/components/Navigation/routes.tsx
+++ b/apps/docs/src/components/Navigation/routes.tsx
@@ -16,7 +16,7 @@ import {
Timer,
Variable,
PencilRuler,
- File,
+ File, TerminalSquare,
} from 'lucide-react'
export const routes = [
@@ -244,6 +244,31 @@ export const routes = [
},
],
},
+ {
+ title: 'CLI API',
+ links: [
+ {
+ icon: (
+ <Settings
+ strokeWidth={1}
+ size={20}
+ />
+ ),
+ title: 'Installation',
+ href: '/cli/installation',
+ },
+ {
+ icon: (
+ <TerminalSquare
+ strokeWidth={1}
+ size={20}
+ />
+ ),
+ title: 'Commands',
+ href: '/cli/commands',
+ },
+ ],
+ },
// {
// title: 'E2B CLI',
// links: [
diff --git a/apps/docs/src/components/mdx.tsx b/apps/docs/src/components/mdx.tsx
index 8a199b8eb..4d77a77cd 100644
--- a/apps/docs/src/components/mdx.tsx
+++ b/apps/docs/src/components/mdx.tsx
@@ -105,7 +105,7 @@ export function Properties({ children }: { children: React.ReactNode }) {
<div className="my-6">
<ul
role="list"
- className="m-0 max-w-[calc(theme(maxWidth.lg)-theme(spacing.8))] list-none divide-y divide-zinc-900/5 p-0 dark:divide-white/5"
+ className="m-0 max-w-[calc(theme(maxWidth.xl)-theme(spacing.4))] list-none divide-y divide-zinc-900/5 p-0 dark:divide-white/5"
>
{children}
</ul>
diff --git a/packages/cli/src/commands/init.ts b/packages/cli/src/commands/init.ts
index 18388f385..9a47ac09d 100644
--- a/packages/cli/src/commands/init.ts
+++ b/packages/cli/src/commands/init.ts
@@ -10,7 +10,7 @@ import { asLocalRelative, asPrimary } from 'src/utils/format'
export const initCommand = new commander.Command('init')
.description(
- `Create basic E2B ${asLocalRelative('e2b.Dockerfile')} in root directory. You can then run ${asPrimary('e2b build')} to build sandbox template from this Dockerfile`,
+ `Create basic E2B Dockerfile (${asLocalRelative('e2b.Dockerfile')}) in root directory. You can then run ${asPrimary('e2b build')} to build sandbox template from this Dockerfile`,
)
.addOption(pathOption)
.alias('it')
diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts
index 87a0921fb..4a0dfb444 100644
--- a/packages/cli/src/index.ts
+++ b/packages/cli/src/index.ts
@@ -4,6 +4,8 @@ import * as updateNotifier from 'update-notifier'
import * as packageJSON from '../package.json'
import { program } from './commands'
+import { Option } from 'commander'
+import * as stripAnsi from 'strip-ansi'
export const pkg = packageJSON
@@ -14,4 +16,15 @@ updateNotifier.default({
program
.version(packageJSON.version, undefined, 'Display E2B CLI version')
- .parse()
+ .addOption(new Option('-cmd2json').hideHelp()).on('option:-cmd2json', () => {
+ process.stdout.write(JSON.stringify((program.commands.map((x: any) => ({
+ command: x.name(),
+ description: stripAnsi.default(x.description()),
+ options: x.options.map((y: any) => ({
+ flags: y.flags,
+ description: stripAnsi.default(y.description),
+ defaultValue: y.defaultValue,
+ })),
+ })))));
+ process.exit();
+ }).parse();