feat(cli): overhaul help formatting with custom argparse HelpFormatter#55
Merged
JacksonFergusonDev merged 3 commits intomainfrom Feb 25, 2026
Merged
feat(cli): overhaul help formatting with custom argparse HelpFormatter#55JacksonFergusonDev merged 3 commits intomainfrom
JacksonFergusonDev merged 3 commits intomainfrom
Conversation
- Introduce `PulsarHelpFormatter` subclassing `argparse.HelpFormatter`
- Override `_format_action` to intercept `_SubParsersAction` and suppress the auto-generated `{command1,command2...}` metavar block
- Update `ArgumentParser` in `main()` to utilize the custom formatter and suppress the default usage line
- Update `PulsarHelpFormatter` to categorize subcommands based on their domain (Backup Management, Repository Control, Maintenance, Service). - Inject custom headers and spacing during the subaction iteration phase to visually separate command clusters.
- Initialize `ArgumentParser` with `add_help=False` to strip the default help behavior. - Manually re-implement `-h` and `--help` flags using `action="help"` but map their help strings to `argparse.SUPPRESS` so they remain functional without cluttering the final options block.
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
The default
argparseoutput forgit pulsar helpwas generating excessive noise, conflating all 18 subcommands into a single massive usage block and an unreadable{command1,command2...}meta-variable string. This PR brings the CLI's help aesthetic in line with the project's "Signal vs. Noise" philosophy by explicitly overridingargparseinternals.Changes
PulsarHelpFormatter): Subclassedargparse.HelpFormatterto intercept_SubParsersActionduring rendering, allowing us to completely bypass the default container formatting and its trailing whitespace artifacts.README.md.usage:line to keep the top-level description clean.-h, --helpflags from the final options block by initializing the parser withadd_help=Falseand manually re-injecting them asargparse.SUPPRESS.Visual Impact
Before:
After: