Skip to content

馃悰 fix: expand {subcommand} to the sub-command name chain - #358

Merged
gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:subcommand-placeholder
Aug 27, 2026
Merged

馃悰 fix: expand {subcommand} to the sub-command name chain#358
gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:subcommand-placeholder

Conversation

@gaborbernat

Copy link
Copy Markdown
Member

{subcommand} in :group_sub_title_prefix: came from parser.prog rather 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 before add_subparsers() the prog is bar root first, so {subcommand} became root, and for a nested command tool a list both tool a and tool a list rendered the heading tool a; the existing test-group-title-prefix-subcommand-replacement expectation encoded the root case.

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 from parser.prog. 馃Л

The updated expectation in test_group_title_prefix_sub_command_replacement reads bar baronlyfirst (f) instead of bar baronlyroot (f).

@gaborbernat gaborbernat added the bug Something isn't working label Aug 27, 2026
@gaborbernat
gaborbernat force-pushed the subcommand-placeholder branch 10 times, most recently from 745142a to 9d1aa04 Compare August 27, 2026 16:38
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
gaborbernat force-pushed the subcommand-placeholder branch from 9d1aa04 to 33f90f2 Compare August 27, 2026 16:39
@gaborbernat
gaborbernat merged commit c7b3d97 into tox-dev:main Aug 27, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant