Repository navigation
Conversation
The root parser and every subparser share the same global options, so the subparser's defaults overwrote values given before the subcommand: `tabcmd --server X --language de login` lost both. Build the subcommand copy of the global options with defaults suppressed so a value from either position is kept, and a value after the subcommand still wins. Co-Authored-By: Claude Code <noreply@anthropic.com>
Covers every global option before and after the subcommand, boolean flag defaults, converters, the full default set, and the help command. Co-Authored-By: Claude Code <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Mutually exclusive global options bypass conflict validation when split across the subcommand, allowing an explicitly supplied proxy to be silently overridden and similar credential and certificate conflicts to go undetected.
1 open issue
What changed in this PR
This PR fixes global options being lost when supplied before a subcommand, while preserving root-level defaults and allowing later values to take precedence.
Changes:
- Gives subcommands and
helpseparate global options with defaults suppressed. - Adds parser regression tests for option placement, value conversion, defaults, and precedence.
| File | Description |
|---|---|
tests/parsers/test_global_options_position.py |
Tests global option handling across multiple commands and help. |
tabcmd/execution/parent_parser.py |
Prevents subcommand defaults from overwriting previously parsed global options. |
Review effort: Balanced
Global options can be given before and after the subcommand, and argparse only enforces mutually exclusive groups within one parser, so 'tabcmd --no-proxy login --proxy host:1' kept both and --no-proxy silently won. Check the pair in Session, where the connection is configured. Co-Authored-By: Claude Code <noreply@anthropic.com>
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.

Global options placed before the subcommand were silently dropped, so
tabcmd -s <url> --token-name n --token-value v loginran with no server or credentials, andtabcmd --language de loginignored the language. Only options placed after the subcommand worked.The root parser and every subcommand parser shared one set of global options with defaults. When a subcommand parser ran, its defaults overwrote the values already parsed before the subcommand. The subcommand parsers now use a copy of the global options with defaults suppressed; the root parser keeps the real defaults, so every option still has a default value. Options given after the subcommand still win over ones given before it.
Tests build the real parser and check every global option gives the same result before and after the subcommand, across several commands and
help. Help output is unchanged.🤖 Generated with Claude Code