馃悰 fix: expand {subcommand} to the sub-command name chain - #358
Merged
Conversation
gaborbernat
force-pushed
the
subcommand-placeholder
branch
10 times, most recently
from
August 27, 2026 16:38
745142a to
9d1aa04
Compare
The placeholder took its value from parser.prog: the first word after the program name for section titles and the whole remainder for group titles. A positional declared before add_subparsers() made it the positional's name, and nested commands collapsed onto their parent's heading. Carry the chain of sub-parser names through the walk and use it for both title kinds. Anchors still derive from parser.prog.
gaborbernat
force-pushed
the
subcommand-placeholder
branch
from
August 27, 2026 16:39
9d1aa04 to
33f90f2
Compare
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.
{subcommand}in:group_sub_title_prefix:came fromparser.prograther than from the sub-parser name: the section title took the first word after the program name, and group titles inside the section took the whole remainder. With a positional argument declared beforeadd_subparsers()the prog isbar root first, so{subcommand}becameroot, and for a nested commandtool a listbothtool aandtool a listrendered the headingtool a; the existingtest-group-title-prefix-subcommand-replacementexpectation encoded therootcase.The sub-parser walk now carries the chain of command names (
first,first nested) and passes it to both the section title and the group titles, so the placeholder expands to the command path in every heading. Anchors do not change since they still derive fromparser.prog. 馃ЛThe updated expectation in
test_group_title_prefix_sub_command_replacementreadsbar baronlyfirst (f)instead ofbar baronlyroot (f).