Skip to content

fix(cli): allow subcommand options to override global options#1062

Open
dsylla wants to merge 1 commit intoruvnet:mainfrom
dsylla:fix/subcommand-format-option-override
Open

fix(cli): allow subcommand options to override global options#1062
dsylla wants to merge 1 commit intoruvnet:mainfrom
dsylla:fix/subcommand-format-option-override

Conversation

@dsylla
Copy link

@dsylla dsylla commented Jan 31, 2026

Summary

  • Fixes bug where subcommand --format option was being validated against global option choices
  • Example: claude-flow process monitor failed with "Invalid value for --format: text. Must be one of: dashboard, compact, json"

Root Cause

The parser applied global option defaults (--format defaulting to 'text') before command resolution. When validating, the subcommand's --format choices (['dashboard', 'compact', 'json']) were checked against the global default value ('text'), causing validation to fail.

Changes

  1. parser.ts: Defer applyDefaults() - no longer called during parse(), moved to CLI after command resolution
  2. parser.ts: Updated applyDefaults() to accept command parameter and skip global defaults when command defines same option
  3. parser.ts: Updated validateFlags() to filter out global options when command overrides them
  4. index.ts: Call applyDefaults(flags, targetCommand) after subcommand resolution

Test Plan

  • claude-flow process monitor now works (uses dashboard format by default)
  • claude-flow process monitor --format json works
  • claude-flow process monitor --format compact works
  • claude-flow --version still works
  • Other commands unaffected

🤖 Generated with claude-flow

The parser was applying global option defaults before command
resolution, causing validation failures when subcommands defined
options with the same name but different choices (e.g., --format).

Changes:
- Defer applyDefaults() call until after command resolution
- Skip global defaults when command defines same option name
- Filter global options from validation when command overrides them

Fixes: `claude-flow process monitor` failing with "Invalid value
for --format: text. Must be one of: dashboard, compact, json"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant