Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/add-open-command.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bunny.net/cli": minor
---

Add `bunny open` command to open the bunny.net dashboard in the default browser. Use `--print` to print the URL instead.
2 changes: 2 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ bunny-cli/
│ │ │ ├── add.ts # Add registry with credentials
│ │ │ └── remove.ts # Remove registry
│ │ ├── docs.ts # Open bunny.net documentation in browser (top-level: bunny docs)
│ │ ├── open.ts # Open bunny.net dashboard in browser (top-level: bunny open)
│ │ └── scripts/
│ │ ├── index.ts # defineNamespace("scripts", ...) — registers all script commands
│ │ ├── constants.ts # SCRIPT_MANIFEST, SCRIPT_TYPE_LABELS
Expand Down Expand Up @@ -773,6 +774,7 @@ bunny
│ ├── list (alias: ls) List all Edge Scripts
│ └── show [id] Show Edge Script details (uses linked script if omitted)
├── docs Open bunny.net documentation in browser
├── open [--print] Open bunny.net dashboard in browser (or print URL)
├── --profile, -p <string> Profile to use (default: "default")
├── --verbose, -v <boolean> Enable verbose output
├── --output, -o <text|json|table|csv|markdown> Output format (default: "text")
Expand Down
14 changes: 14 additions & 0 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,20 @@ bunny whoami --output json
bunny whoami --profile staging
```

### `bunny open`

Open the bunny.net dashboard in your default browser. Uses `BUNNYNET_DASHBOARD_URL` if set, otherwise `https://dash.bunny.net`.

```bash
bunny open

# Print the URL instead of opening it
bunny open --print

# Print as JSON
bunny open --print --output json
```

### `bunny config`

Manage CLI configuration and profiles.
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { authLogoutCommand } from "./commands/auth/logout.ts";
import { configNamespace } from "./commands/config/index.ts";
import { dbNamespace } from "./commands/db/index.ts";
import { docsCommand } from "./commands/docs.ts";
import { openCommand } from "./commands/open.ts";
import { registriesNamespace } from "./commands/registries/index.ts";
import { scriptsNamespace } from "./commands/scripts/index.ts";
import { whoamiCommand } from "./commands/whoami.ts";
Expand All @@ -24,6 +25,7 @@ const commands: CommandModule[] = [
scriptsNamespace,
configNamespace,
docsCommand,
openCommand,
apiCommand,
];

Expand Down
48 changes: 48 additions & 0 deletions packages/cli/src/commands/open.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { defineCommand } from "../core/define-command.ts";
import { logger } from "../core/logger.ts";
import { openBrowser } from "../core/ui.ts";

const DASHBOARD_URL =
process.env.BUNNYNET_DASHBOARD_URL ?? "https://dash.bunny.net";

const COMMAND = "open";
const DESCRIPTION = "Open the bunny.net dashboard in the browser.";

/**
* Open the bunny.net dashboard in the default browser.
*
* @example
* ```bash
* bunny open
* bunny open --print
* ```
*/
export const openCommand = defineCommand<{ print: boolean }>({
command: COMMAND,
describe: DESCRIPTION,
examples: [
["$0 open", "Open the bunny.net dashboard"],
["$0 open --print", "Print the dashboard URL instead of opening it"],
],

builder: (yargs) =>
yargs.option("print", {
type: "boolean",
default: false,
describe: "Print the URL instead of opening it in the browser",
}),

handler: async ({ print, output }) => {
if (print) {
if (output === "json") {
console.log(JSON.stringify({ url: DASHBOARD_URL }));
} else {
console.log(DASHBOARD_URL);
}
return;
}

logger.info(`Opening ${DASHBOARD_URL}`);
openBrowser(DASHBOARD_URL);
},
});