Correct title,name and synopsis in generated man pages for subcommands#5301
Merged
epage merged 2 commits intoclap-rs:masterfrom Jan 29, 2024
Merged
Correct title,name and synopsis in generated man pages for subcommands#5301epage merged 2 commits intoclap-rs:masterfrom
epage merged 2 commits intoclap-rs:masterfrom
Conversation
Print the full command, instead of just the last subcommand in the man page. ex for `git add` print `git-add` instead of simply `add` as the title and name. For the synopsis print the usage string, so `git add`
EdJoPaTo
reviewed
Jan 28, 2024
Contributor
EdJoPaTo
left a comment
There was a problem hiding this comment.
Came across the same issue and found the PR which handles this nearly as expected. I have some thoughts to improve it (and hopefully get it merged sooner than later).
As the CI highlights (cargo test): tests/snapshots/sub_subcommand_help.roff needs an update. (Likely after the synopsis works correctly)
Contributor
Author
|
Thanks to @EdJoPaTo's suggestions all tests are now passing, I also updated the top comment with the new man page before/after. |
Member
|
Thanks! |
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.
Print the "full" command in the name,title, and synopsis of subcommand man pages. Currently if clap was to generate a man page for
git addthe title and name would be simplyadd, notgit-addlike expected, and the synopsis would beadd <args>notgit add <args>To obtain the proper usage string (ex:Fixed thanks to @EdJoPaTo suggestions 🎉git addnotgit-add) I believe we wantCommand.usage_name, but it is private and the only way I could find to obtain it is viaCommand.render_usage()which unfortunately forces an unnecessary clone. This also causes duplication of positional arguments (as can be seen below with<COMMAND>(the struct name) and<subcommands>both appearing in the synopsis. Suggestions on how to fix that are appreciated.Some minimal code to generate a cli with multiple sub (and subsub) commands to reproduce this can be found in my fork here
Additional context can be found in #4231
example (command =
mrc tempfrom my linked test code)Before:
After: