Skip to content
This repository was archived by the owner on Jul 14, 2026. It is now read-only.
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ node_modules/
octomind.config.json
octomind-cli-debug/
openapi.yaml
vhs/

2 changes: 2 additions & 0 deletions README-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ A command-line interface for interacting with the Octomind API.
This CLI allows you to execute tests, retrieve test reports, and manage private locations as well as environments.
See [API documentation](https://octomind.dev/docs/api-reference/)

<img src="assets/octomind-cli-opt.gif" />

## Usage / Installation

1. To install the package globally do **NOT** just a `npm i -g @octomind/octomind` but instead
Expand Down
48 changes: 23 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ A command-line interface for interacting with the Octomind API.
This CLI allows you to execute tests, retrieve test reports, and manage private locations as well as environments.
See [API documentation](https://octomind.dev/docs/api-reference/)

<img src="assets/octomind-cli-opt.gif" />

## Usage / Installation

1. To install the package globally do **NOT** just a `npm i -g @octomind/octomind` but instead
Expand Down Expand Up @@ -40,20 +42,16 @@ This way even entityIds like environmentIds or testCaseIds will be autocompleted

# octomind

Octomind cli tool. Version: 1.3.0. Additional documentation see https://octomind.dev/docs/api-reference/
Octomind cli tool. Version: 1.3.1. Additional documentation see https://octomind.dev/docs/api-reference/

**Usage:** `octomind [options] [command]`

### Options

| Option | Description | Required | Default |
|--------|-------------|----------|--------|
|:-------|:----------|:---------|:--------|
| `-V, --version` | output the version number | No | |

# octomind CLI Documentation

Octomind cli tool. Version: 1.3.0. Additional documentation see https://octomind.dev/docs/api-reference/

## Setup

## init
Expand All @@ -65,7 +63,7 @@ Initialize configuration by setting up API key. This will create a config file i
### Options

| Option | Description | Required | Default |
|--------|-------------|----------|--------|
|:-------|:----------|:---------|:--------|
| `-t, --test-target-id <id>` | Test target ID | Yes | |
| `-k, --api-key <key>` | the api key for authentication | Yes | |
| `-f, --force` | Force overwrite existing configuration | No | |
Expand Down Expand Up @@ -107,7 +105,7 @@ List all environments
### Options

| Option | Description | Required | Default |
|--------|-------------|----------|--------|
|:-------|:----------|:---------|:--------|
| `-j, --json` | Output raw JSON response | No | |
| `-t, --test-target-id [id]` | Test target ID, if not provided will use the test target id from the config | No | |

Expand All @@ -120,7 +118,7 @@ Create a new environment
### Options

| Option | Description | Required | Default |
|--------|-------------|----------|--------|
|:-------|:----------|:---------|:--------|
| `-j, --json` | Output raw JSON response | No | |
| `-n, --name <name>` | Environment name | Yes | |
| `-d, --discovery-url <url>` | Discovery URL | Yes | |
Expand All @@ -141,7 +139,7 @@ Get an environment
### Options

| Option | Description | Required | Default |
|--------|-------------|----------|--------|
|:-------|:----------|:---------|:--------|
| `-j, --json` | Output raw JSON response | No | |
| `-e, --environment-id <id>` | Environment ID | Yes | |
| `-t, --test-target-id [id]` | Test target ID, if not provided will use the test target id from the config | No | |
Expand All @@ -155,7 +153,7 @@ Update an existing environment
### Options

| Option | Description | Required | Default |
|--------|-------------|----------|--------|
|:-------|:----------|:---------|:--------|
| `-j, --json` | Output raw JSON response | No | |
| `-e, --environment-id <id>` | Environment ID | Yes | |
| `-t, --test-target-id [id]` | Test target ID, if not provided will use the test target id from the config | No | |
Expand All @@ -177,7 +175,7 @@ Delete an environment
### Options

| Option | Description | Required | Default |
|--------|-------------|----------|--------|
|:-------|:----------|:---------|:--------|
| `-j, --json` | Output raw JSON response | No | |
| `-e, --environment-id <id>` | Environment ID | Yes | |
| `-t, --test-target-id [id]` | Test target ID, if not provided will use the test target id from the config | No | |
Expand All @@ -193,7 +191,7 @@ run test cases against local build
### Options

| Option | Description | Required | Default |
|--------|-------------|----------|--------|
|:-------|:----------|:---------|:--------|
| `-j, --json` | Output raw JSON response | No | |
| `-u, --url <url>` | url the tests should run against | Yes | |
| `-c, --test-case-id [uuid]` | id of the test case you want to run, if not provided will run all test cases in the test target | No | |
Expand All @@ -212,7 +210,7 @@ Execute test cases to create a test report
### Options

| Option | Description | Required | Default |
|--------|-------------|----------|--------|
|:-------|:----------|:---------|:--------|
| `-j, --json` | Output raw JSON response | No | |
| `-u, --url <url>` | URL to test | Yes | |
| `-t, --test-target-id [id]` | Test target ID, if not provided will use the test target id from the config | No | |
Expand All @@ -230,7 +228,7 @@ Create a new test case discovery
### Options

| Option | Description | Required | Default |
|--------|-------------|----------|--------|
|:-------|:----------|:---------|:--------|
| `-j, --json` | Output raw JSON response | No | |
| `-n, --name <name>` | Discovery name | Yes | |
| `-p, --prompt <prompt>` | Discovery prompt | Yes | |
Expand All @@ -252,7 +250,7 @@ Get notifications for a test target
### Options

| Option | Description | Required | Default |
|--------|-------------|----------|--------|
|:-------|:----------|:---------|:--------|
| `-j, --json` | Output raw JSON response | No | |
| `-t, --test-target-id [id]` | Test target ID, if not provided will use the test target id from the config | No | |

Expand All @@ -267,7 +265,7 @@ Register a private location
### Options

| Option | Description | Required | Default |
|--------|-------------|----------|--------|
|:-------|:----------|:---------|:--------|
| `-j, --json` | Output raw JSON response | No | |
| `-n, --name <name>` | Location name | Yes | |
| `-p, --password <password>` | Proxy password | Yes | |
Expand All @@ -283,7 +281,7 @@ Unregister a private location
### Options

| Option | Description | Required | Default |
|--------|-------------|----------|--------|
|:-------|:----------|:---------|:--------|
| `-j, --json` | Output raw JSON response | No | |
| `-n, --name <name>` | Location name | Yes | |

Expand All @@ -296,7 +294,7 @@ List all private locations
### Options

| Option | Description | Required | Default |
|--------|-------------|----------|--------|
|:-------|:----------|:---------|:--------|
| `-j, --json` | Output raw JSON response | No | |

## start-private-location
Expand All @@ -308,7 +306,7 @@ Start a private location worker, see https://octomind.dev/docs/proxy/private-loc
### Options

| Option | Description | Required | Default |
|--------|-------------|----------|--------|
|:-------|:----------|:---------|:--------|
| `-n, --name [name]` | Location name | No | |
| `-u, --username [username]` | Proxy user | No | |
| `-p, --password [password]` | Proxy password | No | |
Expand All @@ -331,7 +329,7 @@ Delete a test case
### Options

| Option | Description | Required | Default |
|--------|-------------|----------|--------|
|:-------|:----------|:---------|:--------|
| `-j, --json` | Output raw JSON response | No | |
| `-c, --test-case-id <id>` | Test case ID | Yes | |
| `-t, --test-target-id [id]` | Test target ID, if not provided will use the test target id from the config | No | |
Expand All @@ -345,7 +343,7 @@ Get details of a specific test case
### Options

| Option | Description | Required | Default |
|--------|-------------|----------|--------|
|:-------|:----------|:---------|:--------|
| `-j, --json` | Output raw JSON response | No | |
| `-c, --test-case-id <id>` | Test case ID | Yes | |
| `-t, --test-target-id [id]` | Test target ID, if not provided will use the test target id from the config | No | |
Expand All @@ -359,7 +357,7 @@ List all test cases
### Options

| Option | Description | Required | Default |
|--------|-------------|----------|--------|
|:-------|:----------|:---------|:--------|
| `-j, --json` | Output raw JSON response | No | |
| `-t, --test-target-id [id]` | Test target ID, if not provided will use the test target id from the config | No | |

Expand All @@ -374,7 +372,7 @@ Get test report details
### Options

| Option | Description | Required | Default |
|--------|-------------|----------|--------|
|:-------|:----------|:---------|:--------|
| `-j, --json` | Output raw JSON response | No | |
| `-r, --test-report-id <id>` | Test report ID | Yes | |
| `-t, --test-target-id [id]` | Test target ID, if not provided will use the test target id from the config | No | |
Expand All @@ -390,7 +388,7 @@ List all test targets
### Options

| Option | Description | Required | Default |
|--------|-------------|----------|--------|
|:-------|:----------|:---------|:--------|
| `-j, --json` | Output raw JSON response | No | |


Expand Down
Binary file added assets/octomind-cli-opt.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@octomind/octomind",
"version": "1.3.0",
"version": "1.3.1",
"description": "a command line client for octomind apis",
"main": "./dist/index.js",
"packageManager": "pnpm@10.13.1",
Expand Down
5 changes: 1 addition & 4 deletions scripts/generate-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function generateCommandDocs(command: Command, level = 1): string {
if (options && options.length > 0) {
docs += '### Options\n\n';
docs += '| Option | Description | Required | Default |\n';
docs += '|--------|-------------|----------|--------|\n';
docs += '|:-------|:----------|:---------|:--------|\n';

options.forEach(option => {
const flags = option.flags;
Expand All @@ -46,9 +46,6 @@ export function generateCommandDocs(command: Command, level = 1): string {
const subcommands = command.commands;
if (subcommands && subcommands.length > 0) {
if (level === 1) {
docs += `# ${command.name()} CLI Documentation\n\n`;
docs += `${command.description()}\n\n`;

const commandsByGroup = new Map<string, Command[]>();
const ungroupedCommands: Command[] = [];

Expand Down
112 changes: 4 additions & 108 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ import {
unregisterLocation,
updateEnvironment,
} from "./tools";
import { getTestTargets, listTestTargets } from "./tools/test-targets";
import { init, switchTestTarget } from "./tools/init";
import { listTestTargets } from "./tools/test-targets";
import { version } from "./version";

export const BINARY_NAME = "octomind";
Expand All @@ -60,38 +61,6 @@ const addTestTargetWrapper =
void fn({ ...options, testTargetId: resolvedTestTargetId });
};

const selectTestTarget = async (): Promise<string> => {
const testTargets = await getTestTargets();
await listTestTargets({});

if (testTargets.length === 1) {
console.log(
`Only one test target found, using it: ${testTargets[0].app} (${testTargets[0].id})`,
);
return testTargets[0].id;
}

const testTargetIndex = await promptUser(
"Enter number of the test target you want to use (optional, press Enter to skip): ",
);
const testTargetIndexAsInt = Number.parseInt(testTargetIndex);

if (
Number.isNaN(testTargetIndexAsInt) ||
testTargetIndexAsInt < 1 ||
testTargetIndexAsInt > testTargets.length
) {
console.log("❌ could not find a test target with the index you provided");
process.exit(1);
}
const testTargetId = testTargets[testTargetIndexAsInt - 1].id;
if (!testTargetId) {
console.log("❌ could not find a test target with the index you provided");
process.exit(1);
}

return testTargetId;
};
const testTargetIdOption = new Option(
"-t, --test-target-id [id]",
"Test target ID, if not provided will use the test target id from the config",
Expand Down Expand Up @@ -127,88 +96,15 @@ export const buildCmd = (): CompletableCommand => {
.option("-t, --test-target-id <id>", "Test target ID")
.option("-k, --api-key <key>", "the api key for authentication")
.option("-f, --force", "Force overwrite existing configuration")
.action(
async (options: {
testTargetId?: string;
apiKey: string;
force?: boolean;
}) => {
try {
console.log("🚀 Initializing configuration...\n");

const existingConfig = await loadConfig(options.force);

if (existingConfig.apiKey && !options.force) {
console.log("⚠️ Configuration already exists.");
const overwrite = await promptUser(
"Do you want to overwrite it? (y/N): ",
);

if (
overwrite.toLowerCase() !== "y" &&
overwrite.toLowerCase() !== "yes"
) {
console.log("Configuration unchanged.");
return;
}
}

let apiKey: string = "";
if (!options.apiKey) {
apiKey = await promptUser(
"Enter your API key. Go to https://octomind.dev/docs/run-tests/execution-curl#create-an-api-key to learn how to generate one: ",
);
if (!apiKey) {
console.log("❌ API key is required.");
process.exit(1);
}
}
// saving here to be able to use the api key for the test targets
const newApiKeyConfig = {
...existingConfig,

apiKey: options.apiKey,
};

await saveConfig(newApiKeyConfig);

const testTargetId = await selectTestTarget();

const newConfig: Config = {
...existingConfig,
apiKey: options.apiKey,
testTargetId: options.testTargetId ?? testTargetId,
};

await saveConfig(newConfig);

console.log("\n✨ Initialization complete!");
} catch (error) {
console.error(
"❌ Error during initialization:",
(error as Error).message,
);
process.exit(1);
}
},
);
.action(init);

program
.completableCommand("switch-test-target")
.description(
"Switch to a different test target. This will list all available test targets and update the config file in ~/.config/octomind.json",
)
.helpGroup("setup")
.action(async () => {
const testTargetId = await selectTestTarget();
const existingConfig = await loadConfig();
const newConfig: Config = {
...existingConfig,
testTargetId,
};
await saveConfig(newConfig);
console.log(`✨ Switched to test target: ${testTargetId}`);
});
.action(switchTestTarget);

createCommandWithCommonOptions(program, "debug")
.completer(environmentIdCompleter)
Expand Down
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export async function saveConfig(newConfig: Config): Promise<void> {
const configPath = await getConfigPath(true);
await fs.writeFile(configPath, JSON.stringify(newConfig, null, 2), "utf8");
console.log(`✅ Configuration saved to ${configPath}`);
configLoaded = false;
} catch (error) {
console.error("❌ Error saving configuration:", (error as Error).message);
process.exit(1);
Expand Down
Loading