Improve subcommand error help text, CERTTF-917 - #1170
Open
ajzobro wants to merge 4 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the CLI’s argparse error handling so that when argument parsing fails after a subcommand is present, the CLI can display the relevant subcommand help (instead of only top-level help), improving UX for mid-command invalid args (CERTTF-917).
Changes:
- Introduces a custom
ArgumentParsersubclass to overrideerror()and attempt to show subcommand-specific help. - Adds a
_register_subparser()helper and registers many top-level subcommands for improved error/help output. - Wires the main CLI parser to use the new parser subclass.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.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.
Description
Updated the mechanism by which the sub parsers are able to provide help by determining if a subcommand is in use, so that rather than provide the overall help, the individual subcommand can present it's help instead.
Resolved issues
Resolves CERTTF-917
Documentation
This improves the help when invalid args are used mid-way
Web service API changes
N/A
Tests
Manual testing only, review help text and command line behavior.