Skip to content

Commit 7d35c4a

Browse files
committed
fix: omit empty command flag section in help
1 parent 5d199aa commit 7d35c4a

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

src/__tests__/cli-help.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ test('help appstate prints command help and skips daemon dispatch', async () =>
6565
assert.equal(result.code, 0);
6666
assert.equal(result.daemonCalls, 0);
6767
assert.match(result.stdout, /Show foreground app\/activity/);
68-
assert.match(result.stdout, /Command flags:\n \(none\)/);
68+
assert.doesNotMatch(result.stdout, /Command flags:/);
6969
assert.match(result.stdout, /Global flags:/);
7070
});
7171

src/utils/__tests__/args.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,6 @@ test('command usage shows no command flags when unsupported', () => {
188188
const help = usageForCommand('appstate');
189189
if (help === null) throw new Error('Expected command help text');
190190
assert.match(help, /Show foreground app\/activity/);
191-
assert.match(help, /Command flags:\n \(none\)/);
191+
assert.doesNotMatch(help, /Command flags:/);
192192
assert.match(help, /Global flags:/);
193193
});

src/utils/command-schema.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,11 @@ export function buildCommandUsageText(commandName: string): string | null {
611611
const usage = buildCommandUsage(commandName, schema);
612612
const commandFlags = listHelpFlags(new Set<FlagKey>(schema.allowedFlags));
613613
const globalFlags = listHelpFlags(GLOBAL_FLAG_KEYS);
614+
const sections: string[] = [];
615+
if (commandFlags.length > 0) {
616+
sections.push(renderFlagSection('Command flags:', commandFlags));
617+
}
618+
sections.push(renderFlagSection('Global flags:', globalFlags));
614619

615620
return `agent-device ${usage}
616621
@@ -619,8 +624,6 @@ ${schema.description}
619624
Usage:
620625
agent-device ${usage}
621626
622-
${renderFlagSection('Command flags:', commandFlags)}
623-
624-
${renderFlagSection('Global flags:', globalFlags)}
627+
${sections.join('\n\n')}
625628
`;
626629
}

0 commit comments

Comments
 (0)