Repository navigation
fix: pass -h/--help to subcommands in CLI dispatcher - #192
Open
Siddharth S (codeXsidd) wants to merge 1 commit into
Open
Siddharth S (codeXsidd) wants to merge 1 commit into
Siddharth S (codeXsidd) wants to merge 1 commit into
Conversation
The top-level ArgumentParser intercepted -h and --help even when a subcommand was specified, preventing users from seeing the subcommand's options and usage. Delegate directly to the specified subcommand when it is recognized, and add -h/--help support to show.py. Fixes qualcomm-linux#191 Signed-off-by: codeXsidd <siddharth291206@gmail.com>
Siddharth S (codeXsidd)
requested review from
Dmitry Baryshkov (lumag),
Nicolas Dechesne (ndechesne) and
Viswanath Kraleti (vkraleti)
as code owners
October 22, 2026 11:25
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
Pass command-line arguments (including
-hand--help) directly to the selected subcommand inqcom-ptoolCLI dispatcher, and add-h/--helphandling toshow.py.Problem
When invoking
qcom-ptool <subcommand> -horqcom-ptool <subcommand> --help(e.g.qcom-ptool gen_partition -h), the top-levelArgumentParserintercepted-h/--helpand displayed the top-levelqcom-ptoolhelp instead of delegating to the subcommand's help handler. This made it impossible to inspect options accepted by subcommands despite the help text and README stating:Run 'qcom-ptool <subcommand> -h' to see the options accepted by each subcommand.In addition,
qcom_ptool/show.pylacked-hand--helpflags in its option list, causing it to printoption -h not recognizedand exit with code 1.Solution
qcom_ptool/cli.py: If the first positional argument is a recognized subcommand, pass all remaining arguments directly to that subcommand instead of letting the top-levelArgumentParserintercept them.qcom_ptool/show.py: Added-h/--helpoption parsing and an optionalexit_codeparameter tousage()so--helpexits cleanly with code 0.tests/unit/test_cli.py: Added parameterized tests verifying that-his passed through to each subcommand without displaying the top-level epilog, and verified thatshow -h/show --helpexit with 0 and print usage.Testing
pytest: 178 unit tests passed (including new CLI pass-through and show help tests)ruff check qcom_ptool tests/unit/test_cli.py: All checks passed with 0 errorsmypy qcom_ptool/cli.py qcom_ptool/show.py: Success, no issues found in 2 source filesgit diff --check: Clean, no trailing whitespace or formatting errorsRelated Issue
Closes #191