Fix: Remove short flags from non-boolean typer.Option definitions#49
Open
Vadiml1024 wants to merge 2 commits intoChat2AnyLLM:mainfrom
Open
Fix: Remove short flags from non-boolean typer.Option definitions#49Vadiml1024 wants to merge 2 commits intoChat2AnyLLM:mainfrom
Vadiml1024 wants to merge 2 commits intoChat2AnyLLM:mainfrom
Conversation
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>
This fixes the AttributeError: 'Flag' object has no attribute 'default' error that occurred when running `cam --help` and other help commands. The issue was caused by Typer 0.12.x having incompatibilities with the Flag() definition syntax used in the codebase. Typer 0.16.0+ includes the necessary fixes for proper Flag handling. Changes: - Updated typer dependency from >=0.12.0 to >=0.16.0 in pyproject.toml Testing: - Verified `cam --help` displays correctly without errors - Verified subcommands help work: `cam agent --help`, `cam plugin --help`, `cam mcp --help` - All commands now show proper help output with formatted options and commands Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #48
Problem
CAM failed to initialize with
TypeError: Secondary flag is not valid for non-boolean flagwhen 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
1. Fixed Short Flag Definitions (Commit: af64dfe)
typer.Optiondefinitions across 12 filesprompts_commands.pywhere thedefaultparameter name conflicted with boolean flag syntaxTrue/Falseas first argument) retain their short flags as they are allowed2. Fixed Typer Version Incompatibility (Commit: 2545df3)
During testing, we discovered a second bug: The project required
typer>=0.13.0, but short flags for booleans were only added in Typer 0.16.0. This caused an error:Fix: Upgraded minimum Typer version from
>=0.13.0to>=0.16.0inpyproject.tomlto ensure short flag support works correctly.Changes
Files Modified (13 total)
cli/agents_commands.pycli/app.pycli/options.pycli/plugins/plugin_discovery_commands.pycli/plugins/plugin_install_commands.pycli/plugins/plugin_management_commands.pycli/plugins/plugin_marketplace_commands.pycli/prompts_commands.pycli/skills_commands.pymcp/cli.pymcp/install_commands.pymcp/server_commands.pypyproject.toml(Typer version update)Example Changes
Before:
After:
Boolean flags (unchanged):
Version update in pyproject.toml:
Testing
Verified that CLI initializes successfully without errors:
Impact
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→--ownerHowever, 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. The Typer version incompatibility was discovered during testing and fixed in a follow-up commit.