Repository navigation
Conversation
After "--", ArgParser::parse jumped to the positional handling, which still compared the argument with the subcommand names and their one-letter aliases. Files named c, d, train, etc. could therefore not be passed to zli even after "--". Skip subcommand matching after "--" once a subcommand has been chosen.
This branch has not been deployed
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.
Summary
After
--,ArgParser::parsejumps to the positional handling, but that code first checks the argument against the subcommand names and their one-letter aliases. As a resultzli compress --profile serial -o c.zl -- cfails with "Trying to choose another subcommand 'compress' when one is already chosen (compress)". So there is no way to pass a file namedc,d,t,train,compress, etc.This change skips the subcommand matching after
--once a subcommand has been chosen, so the argument becomes a positional of that subcommand. The following still work as before:--, a second subcommand name is still rejected.zli -- compress ...still selects the subcommand, because none was chosen yet.Type of Change
Bug fix (non-breaking change which fixes an issue)
Test Plan
tools/arg/tests/arg_parser_test.cpp:SubcommandNameAfterEndOfOptionsIsPositionalparsestest -- tandtest -- test. It fails ondev(the parser throws "Trying to choose another subcommand 'test' ...") and passes with the change.SubcommandAfterEndOfOptionschecks that-- test filestill selects the subcommand.test_arg_parser: 12/12 pass.cli_util_test: 11/11 pass.cli/tests/cli_integration_tests.pyagainst the rebuiltzli: 24 tests OK.zli compress --profile serial -o c.zl -- cnow works, andzli decompress -o c.out -- c.zlrestores an identical file.zli compress c -o c2.zl --profile serial(without--) still gives the same error as before.clang-format --dry-run --Werroron both changed files: clean.Test Configuration
-fsanitize=address,undefinedThis change was drafted with Claude Code (claude-opus-5-5); the test results above are from the runs described.