Skip to content

Commit 73f66c7

Browse files
committed
feat: improve CLI help structure
1 parent 5c1601c commit 73f66c7

2 files changed

Lines changed: 160 additions & 25 deletions

File tree

src/utils/__tests__/args.test.ts

Lines changed: 56 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -456,21 +456,15 @@ test('parseArgs rejects invalid swipe pattern', () => {
456456
);
457457
});
458458

459-
test('usage includes --relaunch flag', () => {
460-
assert.match(usage(), /--relaunch/);
459+
test('usage includes concise commands and global flags', () => {
461460
assert.match(usage(), /install-from-source <url>/);
462461
assert.match(usage(), /metro prepare/);
463-
assert.match(usage(), /--header <name:value>/);
464-
assert.match(usage(), /--public-base-url <url>/);
465-
assert.match(usage(), /--restart/);
466462
assert.match(usage(), /--target mobile\|tv/);
467463
assert.match(usage(), /--ios-simulator-device-set <path>/);
468464
assert.match(usage(), /--android-device-allowlist <serials>/);
469-
assert.match(usage(), /--fps <n>/);
470465
assert.match(usage(), /network dump/);
471-
assert.match(usage(), /--save-script \[path\]/);
472-
assert.match(usage(), /clipboard read \| clipboard write <text>/);
473-
assert.match(usage(), /keyboard \[status\|get\|dismiss\]/);
466+
assert.match(usage(), /clipboard read\|write \[text\]/);
467+
assert.match(usage(), /keyboard \[action\]/);
474468
assert.match(usage(), /trigger-app-event <event> \[payloadJson\]/);
475469
assert.match(usage(), /pinch <scale> \[x\] \[y\]/);
476470
assert.match(usage(), /--state-dir <path>/);
@@ -480,6 +474,34 @@ test('usage includes --relaunch flag', () => {
480474
assert.match(usage(), /--session-isolation none\|tenant/);
481475
assert.match(usage(), /--run-id <id>/);
482476
assert.match(usage(), /--lease-id <id>/);
477+
assert.match(usage(), /Agent Skills:/);
478+
assert.match(usage(), /agent-device\s+Canonical mobile automation flows/);
479+
assert.match(usage(), /dogfood\s+Exploratory QA and bug hunts/);
480+
assert.match(usage(), /See `skills\/<name>\/SKILL\.md` in the installed package\./);
481+
assert.match(usage(), /Configuration:/);
482+
assert.match(
483+
usage(),
484+
/Default config files: ~\/\.agent-device\/config\.json, \.\/agent-device\.json/,
485+
);
486+
assert.match(
487+
usage(),
488+
/Use --config <path> or AGENT_DEVICE_CONFIG to load one explicit config file\./,
489+
);
490+
assert.match(usage(), /Environment:/);
491+
assert.match(usage(), /AGENT_DEVICE_SESSION\s+Default session name/);
492+
assert.match(usage(), /AGENT_DEVICE_PLATFORM\s+Default platform binding/);
493+
assert.match(usage(), /AGENT_DEVICE_SESSION_LOCK\s+Bound-session conflict mode/);
494+
assert.match(usage(), /AGENT_DEVICE_DAEMON_BASE_URL\s+Connect to remote daemon/);
495+
assert.match(usage(), /Examples:/);
496+
assert.match(usage(), /agent-device open Settings --platform ios/);
497+
assert.match(usage(), /agent-device snapshot -i/);
498+
assert.match(usage(), /agent-device fill @e3 "test@example\.com"/);
499+
assert.match(usage(), /agent-device replay \.\/session\.ad/);
500+
assert.doesNotMatch(usage(), /--relaunch/);
501+
assert.doesNotMatch(usage(), /--header <name:value>/);
502+
assert.doesNotMatch(usage(), /--restart/);
503+
assert.doesNotMatch(usage(), /--fps <n>/);
504+
assert.doesNotMatch(usage(), /--save-script \[path\]/);
483505
assert.doesNotMatch(usage(), /--metadata/);
484506
});
485507

@@ -617,13 +639,23 @@ test('invalid range errors are deterministic', () => {
617639

618640
test('usage includes swipe and press series options', () => {
619641
const help = usage();
620-
assert.match(help, /diff snapshot/);
642+
assert.match(help, /diff <kind>/);
621643
assert.match(help, /swipe <x1> <y1> <x2> <y2>/);
622-
assert.match(help, /--pattern one-way\|ping-pong/);
623-
assert.match(help, /--interval-ms/);
624-
assert.match(help, /settings <wifi\|airplane\|location> <on\|off>/);
625-
assert.match(help, /settings appearance <light\|dark\|toggle>/);
626-
assert.match(help, /settings permission <grant\|deny\|reset>/);
644+
assert.match(help, /settings \[area\] \[options\]/);
645+
assert.doesNotMatch(help, /--pattern one-way\|ping-pong/);
646+
assert.doesNotMatch(help, /--interval-ms/);
647+
});
648+
649+
test('usage renders concise commands inline with descriptions', () => {
650+
const help = usage();
651+
assert.match(help, /Commands:[\s\S]*\n boot\s{2,}Boot target device\/simulator/);
652+
assert.match(help, / metro prepare\s{2,}Prepare local Metro runtime/);
653+
assert.match(help, / session list\s{2,}List active sessions/);
654+
assert.doesNotMatch(help, / metro prepare[^\n]*--project-root/);
655+
assert.doesNotMatch(
656+
help,
657+
/Prepare a local Metro runtime and optionally bridge it through agent-device-proxy/,
658+
);
627659
});
628660

629661
test('command usage shows command and global flags separately', () => {
@@ -636,6 +668,15 @@ test('command usage shows command and global flags separately', () => {
636668
assert.match(help, /--platform ios\|android\|apple/);
637669
});
638670

671+
test('command usage keeps detailed descriptions', () => {
672+
const help = usageForCommand('metro');
673+
if (help === null) throw new Error('Expected command help text');
674+
assert.match(
675+
help,
676+
/Prepare a local Metro runtime and optionally bridge it through agent-device-proxy/,
677+
);
678+
});
679+
639680
test('command usage shows no command flags when unsupported', () => {
640681
const help = usageForCommand('appstate');
641682
if (help === null) throw new Error('Expected command help text');

0 commit comments

Comments
 (0)