Skip to content

Conversation

@Vadiml1024
Copy link

Fixes #48

Problem

CAM failed to initialize with TypeError: Secondary flag is not valid for non-boolean flag when running any command. The error occurred during Typer/Click CLI initialization, making the tool completely unusable.

Root Cause

Throughout the codebase, non-boolean typer.Option() definitions incorrectly included short flags (e.g., -c, -s, -n, -o, -b, -f, -d, -a, -l, -m).

In Click/Typer, only boolean flags can have both a long form (--flag) and short form (-f). Non-boolean options (strings, paths, integers, etc.) can only use long-form flags.

Solution

  • Removed short flags from all non-boolean typer.Option definitions across 12 files
  • Fixed parameter name conflict in prompts_commands.py where the default parameter name conflicted with boolean flag syntax
  • Boolean options (with True/False as first argument) retain their short flags as they are allowed

Changes

Files Modified (12 total)

  • cli/agents_commands.py
  • cli/app.py
  • cli/options.py
  • cli/plugins/plugin_discovery_commands.py
  • cli/plugins/plugin_install_commands.py
  • cli/plugins/plugin_management_commands.py
  • cli/plugins/plugin_marketplace_commands.py
  • cli/prompts_commands.py
  • cli/skills_commands.py
  • mcp/cli.py
  • mcp/install_commands.py
  • mcp/server_commands.py

Example Changes

Before:

CONFIG_FILE_OPTION = typer.Option(None, "--config", "-c", help="Path to config file")
SCOPE_OPTION = typer.Option("user", "--scope", "-s", help="Configuration scope")

After:

CONFIG_FILE_OPTION = typer.Option(None, "--config", help="Path to config file")
SCOPE_OPTION = typer.Option("user", "--scope", help="Configuration scope")

Boolean flags (unchanged):

DEBUG_OPTION = typer.Option(False, "--debug", "-d", help="Enable debug logging")
FORCE_OPTION = typer.Option(False, "--force", "-f", help="Skip confirmation prompt")

Testing

Verified that CLI initializes successfully without errors:

from code_assistant_manager.cli import app
from typer.main import get_command
cmd = get_command(app)  # ✓ No TypeError raised

Impact

  • Before: Tool completely unusable - all commands failed on initialization
  • After: Tool works as expected, all commands initialize properly

Breaking Changes

Users who were using short flags for non-boolean options will need to switch to long flags:

  • -c--config
  • -s--scope
  • -n--name
  • -o--owner
  • etc.

However, since the tool was completely broken before this fix, there are likely no active users relying on these short flags.


Note: This PR was created with assistance from Claude Code after discovering and documenting the issue in #48.

Fixes Chat2AnyLLM#48

## Problem
CAM failed to initialize with "TypeError: Secondary flag is not valid
for non-boolean flag" when running any command. The error occurred during
Typer/Click CLI initialization.

## Root Cause
Throughout the codebase, non-boolean typer.Option() definitions incorrectly
included short flags (e.g., -c, -s, -n, -o, -b, -f, -d, -a, -l, -m).

In Click/Typer, only boolean flags can have both a long form (--flag) and
short form (-f). Non-boolean options (strings, paths, integers, etc.) can
only use long-form flags.

## Changes
- Removed short flags from all non-boolean typer.Option definitions across
  12 files in cli/ and mcp/ directories
- Fixed parameter name conflict in prompts_commands.py where 'default'
  parameter conflicted with boolean flag syntax
- Boolean options (with True/False as first argument) retain their short flags

## Affected Files
- cli/agents_commands.py
- cli/app.py
- cli/options.py
- cli/plugins/plugin_discovery_commands.py
- cli/plugins/plugin_install_commands.py
- cli/plugins/plugin_management_commands.py
- cli/plugins/plugin_marketplace_commands.py
- cli/prompts_commands.py
- cli/skills_commands.py
- mcp/cli.py
- mcp/install_commands.py
- mcp/server_commands.py

## Testing
Verified that CLI initializes successfully and no TypeError is raised:
```python
from code_assistant_manager.cli import app
from typer.main import get_command
cmd = get_command(app)  # No error
```

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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.

Critical: TypeError on CLI initialization - 'Secondary flag is not valid for non-boolean flag'

1 participant