fix: share CLI flags between main parser and optimize subparser#2062
Open
mashraf-222 wants to merge 1 commit intomainfrom
Open
fix: share CLI flags between main parser and optimize subparser#2062mashraf-222 wants to merge 1 commit intomainfrom
mashraf-222 wants to merge 1 commit intomainfrom
Conversation
30 CLI flags (--verbose, --no-pr, --file, --function, etc.) were defined only on the main parser and silently dropped when using the `optimize` subparser path. Uses argparse `parents=[]` pattern to share flags between both parsers. Also adds --trace-only flag and aligns max_function_count default to 256. Co-Authored-By: Claude Opus 4.6 <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.
Problem
30 CLI flags (
--verbose,--no-pr,--file,--function,--all,--trace-only, etc.) were defined only on the mainArgumentParser. When using theoptimizesubparser path (codeflash optimize mvn test ...), these flags were silently dropped by argparse — the subparser didn't recognize them and they were treated as part of the Java command.This broke virtually every flag for the
optimizesubparser path, which is the primary entry point for Java optimization.Root Cause
_build_parser()incli.pyadded all 30+ flags to the main parser only. Theoptimizesubparser was created withsubparsers.add_parser("optimize")but didn't inherit any of these flags.Fix
Used argparse's
parents=[]pattern:shared_flags = ArgumentParser(add_help=False)containing all shared flagsparents=[shared_flags]--trace-onlyflag (was missing entirely)max_function_countdefault to 256 (was 100 on subparser vs 256 elsewhere)Test Coverage
tests/test_cli_args.py:--verbose,--no-pr,--file,--function, multiple flags, command isolation, max_function_count default)Testing