Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

feat(cua-cli): improve help output clarity with command grouping guidance

f-trycua56a6f09a0793
diff --git a/libs/typescript/cua-cli/src/cli.ts b/libs/typescript/cua-cli/src/cli.ts
index aba1dd5d5d..60d68698a6 100644
--- a/libs/typescript/cua-cli/src/cli.ts
+++ b/libs/typescript/cua-cli/src/cli.ts
@@ -4,7 +4,16 @@ import { registerAuthCommands } from './commands/auth';
import { registerSandboxCommands } from './commands/sandbox';
export async function runCli() {
- let argv = yargs(hideBin(process.argv)).scriptName('cua');
+ let argv = yargs(hideBin(process.argv))
+ .scriptName('cua')
+ .usage('Usage: $0 <command> [options]')
+ .epilogue(
+ 'Grouped Commands (recommended):\n' +
+ ' cua auth <command> Manage authentication (login, env, logout)\n' +
+ ' cua sb <command> Manage sandboxes (list, create, start, stop, etc.)\n' +
+ '\n' +
+ 'For more information: https://docs.cua.ai/libraries/cua-cli/commands'
+ );
argv = registerAuthCommands(argv);
argv = registerSandboxCommands(argv);
await argv.demandCommand(1).strict().help().parseAsync();
diff --git a/libs/typescript/cua-cli/src/commands/auth.ts b/libs/typescript/cua-cli/src/commands/auth.ts
index c26d5e0243..18c9cc85ab 100644
--- a/libs/typescript/cua-cli/src/commands/auth.ts
+++ b/libs/typescript/cua-cli/src/commands/auth.ts
@@ -28,24 +28,32 @@ const logoutHandler = async (_argv: Record<string, unknown>) => {
};
export function registerAuthCommands(y: Argv) {
- // Flat structure (backwards compatible)
- y.command(
- 'login',
- 'Open browser to authorize and store API key',
- (y) =>
+ // Flat structure (backwards compatible, hidden from help)
+ y.command({
+ command: 'login',
+ describe: 'Open browser to authorize and store API key',
+ hidden: true,
+ builder: (y: Argv) =>
y.option('api-key', {
type: 'string',
describe: 'API key to store directly',
}),
- loginHandler
- )
- .command(
- 'env',
- 'Create or update .env with CUA_API_KEY (login if needed)',
- () => {},
- envHandler
- )
- .command('logout', 'Remove stored API key', () => {}, logoutHandler);
+ handler: loginHandler,
+ } as any)
+ .command({
+ command: 'env',
+ describe: 'Create or update .env with CUA_API_KEY (login if needed)',
+ hidden: true,
+ builder: (y: Argv) => y,
+ handler: envHandler,
+ } as any)
+ .command({
+ command: 'logout',
+ describe: 'Remove stored API key',
+ hidden: true,
+ builder: (y: Argv) => y,
+ handler: logoutHandler,
+ } as any);
// Grouped structure: cua auth <command>
y.command(
diff --git a/libs/typescript/cua-cli/src/commands/sandbox.ts b/libs/typescript/cua-cli/src/commands/sandbox.ts
index c15e9e763a..04e3c3d517 100644
--- a/libs/typescript/cua-cli/src/commands/sandbox.ts
+++ b/libs/typescript/cua-cli/src/commands/sandbox.ts
@@ -223,22 +223,24 @@ const openHandler = async (argv: Record<string, unknown>) => {
// Register commands in both flat and grouped structures
export function registerSandboxCommands(y: Argv) {
- // Flat structure (backwards compatible)
- y.command(
- ['list', 'ls', 'ps'],
- 'List sandboxes',
- (y) =>
+ // Flat structure (backwards compatible, hidden from help)
+ y.command({
+ command: ['list', 'ls', 'ps'],
+ describe: 'List sandboxes',
+ hidden: true,
+ builder: (y: Argv) =>
y.option('show-passwords', {
type: 'boolean',
default: false,
describe: 'Show sandbox passwords in output',
}),
- listHandler
- )
- .command(
- 'create',
- 'Create a new sandbox',
- (y) =>
+ handler: listHandler,
+ } as any)
+ .command({
+ command: 'create',
+ describe: 'Create a new sandbox',
+ hidden: true,
+ builder: (y: Argv) =>
y
.option('os', {
type: 'string',
@@ -263,38 +265,43 @@ export function registerSandboxCommands(y: Argv) {
demandOption: true,
describe: 'Sandbox region',
}),
- createHandler
- )
- .command(
- 'delete <name>',
- 'Delete a sandbox',
- (y) => y.positional('name', { type: 'string', describe: 'Sandbox name' }),
- deleteHandler
- )
- .command(
- 'start <name>',
- 'Start a sandbox',
- (y) => y.positional('name', { type: 'string', describe: 'Sandbox name' }),
- startHandler
- )
- .command(
- 'stop <name>',
- 'Stop a sandbox',
- (y) => y.positional('name', { type: 'string', describe: 'Sandbox name' }),
- stopHandler
- )
- .command(
- 'restart <name>',
- 'Restart a sandbox',
- (y) => y.positional('name', { type: 'string', describe: 'Sandbox name' }),
- restartHandler
- )
- .command(
- ['vnc <name>', 'open <name>'],
- 'Open VNC desktop for a sandbox',
- (y) => y.positional('name', { type: 'string', describe: 'Sandbox name' }),
- openHandler
- );
+ handler: createHandler,
+ } as any)
+ .command({
+ command: 'delete <name>',
+ describe: 'Delete a sandbox',
+ hidden: true,
+ builder: (y: Argv) => y.positional('name', { type: 'string', describe: 'Sandbox name' }),
+ handler: deleteHandler,
+ } as any)
+ .command({
+ command: 'start <name>',
+ describe: 'Start a sandbox',
+ hidden: true,
+ builder: (y: Argv) => y.positional('name', { type: 'string', describe: 'Sandbox name' }),
+ handler: startHandler,
+ } as any)
+ .command({
+ command: 'stop <name>',
+ describe: 'Stop a sandbox',
+ hidden: true,
+ builder: (y: Argv) => y.positional('name', { type: 'string', describe: 'Sandbox name' }),
+ handler: stopHandler,
+ } as any)
+ .command({
+ command: 'restart <name>',
+ describe: 'Restart a sandbox',
+ hidden: true,
+ builder: (y: Argv) => y.positional('name', { type: 'string', describe: 'Sandbox name' }),
+ handler: restartHandler,
+ } as any)
+ .command({
+ command: ['vnc <name>', 'open <name>'],
+ describe: 'Open VNC desktop for a sandbox',
+ hidden: true,
+ builder: (y: Argv) => y.positional('name', { type: 'string', describe: 'Sandbox name' }),
+ handler: openHandler,
+ } as any);
// Grouped structure: cua sandbox <command> or cua sb <command>
y.command(