fix: enable positional options so -o works on subcommands

Remove global -o/--output from parent program and enable
enablePositionalOptions() so -o yaml/json is parsed by subcommands.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Michal
2026-02-22 16:43:35 +00:00
parent f9458dffa0
commit ede9e10990
2 changed files with 4 additions and 3 deletions

View File

@@ -25,7 +25,7 @@ export function createProgram(): Command {
.name(APP_NAME) .name(APP_NAME)
.description('Manage MCP servers like kubectl manages containers') .description('Manage MCP servers like kubectl manages containers')
.version(APP_VERSION, '-v, --version') .version(APP_VERSION, '-v, --version')
.option('-o, --output <format>', 'output format (table, json, yaml)', 'table') .enablePositionalOptions()
.option('--daemon-url <url>', 'mcplocal daemon URL') .option('--daemon-url <url>', 'mcplocal daemon URL')
.option('--direct', 'bypass mcplocal and connect directly to mcpd'); .option('--direct', 'bypass mcplocal and connect directly to mcpd');

View File

@@ -24,9 +24,10 @@ describe('createProgram', () => {
expect(status).toBeDefined(); expect(status).toBeDefined();
}); });
it('has output option', () => { it('subcommands have output option', () => {
const program = createProgram(); const program = createProgram();
const opt = program.options.find((o) => o.long === '--output'); const get = program.commands.find((c) => c.name() === 'get');
const opt = get?.options.find((o) => o.long === '--output');
expect(opt).toBeDefined(); expect(opt).toBeDefined();
}); });