Skip to content

Commit 6abdab8

Browse files
committed
refactor: simplify CLI help schema
1 parent 73f66c7 commit 6abdab8

2 files changed

Lines changed: 197 additions & 154 deletions

File tree

src/utils/__tests__/args.test.ts

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

459-
test('usage includes concise commands and global flags', () => {
460-
assert.match(usage(), /install-from-source <url>/);
461-
assert.match(usage(), /metro prepare/);
462-
assert.match(usage(), /--target mobile\|tv/);
463-
assert.match(usage(), /--ios-simulator-device-set <path>/);
464-
assert.match(usage(), /--android-device-allowlist <serials>/);
465-
assert.match(usage(), /network dump/);
466-
assert.match(usage(), /clipboard read\|write \[text\]/);
467-
assert.match(usage(), /keyboard \[action\]/);
468-
assert.match(usage(), /trigger-app-event <event> \[payloadJson\]/);
469-
assert.match(usage(), /pinch <scale> \[x\] \[y\]/);
470-
assert.match(usage(), /--state-dir <path>/);
471-
assert.match(usage(), /--daemon-transport auto\|socket\|http/);
472-
assert.match(usage(), /--daemon-server-mode socket\|http\|dual/);
473-
assert.match(usage(), /--tenant <id>/);
474-
assert.match(usage(), /--session-isolation none\|tenant/);
475-
assert.match(usage(), /--run-id <id>/);
476-
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:/);
459+
test('usage includes concise top-level commands', () => {
460+
const usageText = usage();
461+
assert.match(usageText, /install-from-source <url>/);
462+
assert.match(usageText, /metro prepare/);
463+
assert.match(usageText, /network dump/);
464+
assert.match(usageText, /clipboard read\|write \[text\]/);
465+
assert.match(usageText, /keyboard \[action\]/);
466+
assert.match(usageText, /trigger-app-event <event> \[payloadJson\]/);
467+
assert.match(usageText, /pinch <scale> \[x\] \[y\]/);
468+
});
469+
470+
test('usage includes only global flags in the top-level flags section', () => {
471+
const usageText = usage();
472+
assert.match(usageText, /--target mobile\|tv/);
473+
assert.match(usageText, /--ios-simulator-device-set <path>/);
474+
assert.match(usageText, /--android-device-allowlist <serials>/);
475+
assert.match(usageText, /--state-dir <path>/);
476+
assert.match(usageText, /--daemon-transport auto\|socket\|http/);
477+
assert.match(usageText, /--daemon-server-mode socket\|http\|dual/);
478+
assert.match(usageText, /--tenant <id>/);
479+
assert.match(usageText, /--session-isolation none\|tenant/);
480+
assert.match(usageText, /--run-id <id>/);
481+
assert.match(usageText, /--lease-id <id>/);
482+
assert.doesNotMatch(usageText, /--relaunch/);
483+
assert.doesNotMatch(usageText, /--header <name:value>/);
484+
assert.doesNotMatch(usageText, /--restart/);
485+
assert.doesNotMatch(usageText, /--fps <n>/);
486+
assert.doesNotMatch(usageText, /--save-script \[path\]/);
487+
assert.doesNotMatch(usageText, /--metadata/);
488+
});
489+
490+
test('usage includes skills, config, environment, and examples footers', () => {
491+
const usageText = usage();
492+
assert.match(usageText, /Agent Skills:/);
493+
assert.match(usageText, /agent-device\s+Canonical mobile automation flows/);
494+
assert.match(usageText, /dogfood\s+Exploratory QA and bug hunts/);
495+
assert.match(usageText, /See `skills\/<name>\/SKILL\.md` in the installed package\./);
496+
assert.match(usageText, /Configuration:/);
482497
assert.match(
483-
usage(),
498+
usageText,
484499
/Default config files: ~\/\.agent-device\/config\.json, \.\/agent-device\.json/,
485500
);
486501
assert.match(
487-
usage(),
502+
usageText,
488503
/Use --config <path> or AGENT_DEVICE_CONFIG to load one explicit config file\./,
489504
);
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\]/);
505-
assert.doesNotMatch(usage(), /--metadata/);
505+
assert.match(usageText, /Environment:/);
506+
assert.match(usageText, /AGENT_DEVICE_SESSION\s+Default session name/);
507+
assert.match(usageText, /AGENT_DEVICE_PLATFORM\s+Default platform binding/);
508+
assert.match(usageText, /AGENT_DEVICE_SESSION_LOCK\s+Bound-session conflict mode/);
509+
assert.match(usageText, /AGENT_DEVICE_DAEMON_BASE_URL\s+Connect to remote daemon/);
510+
assert.match(usageText, /Examples:/);
511+
assert.match(usageText, /agent-device open Settings --platform ios/);
512+
assert.match(usageText, /agent-device snapshot -i/);
513+
assert.match(usageText, /agent-device fill @e3 "test@example\.com"/);
514+
assert.match(usageText, /agent-device replay \.\/session\.ad/);
506515
});
507516

508517
test('apps defaults to --all filter and allows overrides', () => {

0 commit comments

Comments
 (0)