Skip to content

Improve subcommand error help text, CERTTF-917 - #1170

Open
ajzobro wants to merge 4 commits into
mainfrom
better-help-for-subcommands
Open

Improve subcommand error help text, CERTTF-917#1170
ajzobro wants to merge 4 commits into
mainfrom
better-help-for-subcommands

Conversation

@ajzobro

@ajzobro ajzobro commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ArgumentParser subclass to override error() 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.

Comment thread cli/testflinger_cli/__init__.py
Comment thread cli/testflinger_cli/__init__.py Outdated
Comment thread cli/testflinger_cli/__init__.py
Comment thread cli/testflinger_cli/__init__.py
@ajzobro ajzobro added this to the 26.10.15 milestone Jul 2, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants