From 02254f2aacc6bdc37aecff670ffda2c992e9c46a Mon Sep 17 00:00:00 2001 From: Michal Date: Sun, 22 Feb 2026 16:43:35 +0000 Subject: [PATCH] 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 --- src/cli/src/index.ts | 2 +- src/cli/tests/cli.test.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cli/src/index.ts b/src/cli/src/index.ts index 9e1976f..852a3cf 100644 --- a/src/cli/src/index.ts +++ b/src/cli/src/index.ts @@ -25,7 +25,7 @@ export function createProgram(): Command { .name(APP_NAME) .description('Manage MCP servers like kubectl manages containers') .version(APP_VERSION, '-v, --version') - .option('-o, --output ', 'output format (table, json, yaml)', 'table') + .enablePositionalOptions() .option('--daemon-url ', 'mcplocal daemon URL') .option('--direct', 'bypass mcplocal and connect directly to mcpd'); diff --git a/src/cli/tests/cli.test.ts b/src/cli/tests/cli.test.ts index 2a82ff7..f9bbdcb 100644 --- a/src/cli/tests/cli.test.ts +++ b/src/cli/tests/cli.test.ts @@ -24,9 +24,10 @@ describe('createProgram', () => { expect(status).toBeDefined(); }); - it('has output option', () => { + it('subcommands have output option', () => { 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(); });