Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add man page generation #11

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Add man page generation #11

wants to merge 2 commits into from

Conversation

nihaals
Copy link
Owner

@nihaals nihaals commented Nov 23, 2022

Closes #10

@nihaals
Copy link
Owner Author

nihaals commented Nov 23, 2022

As clap_mangen currently only supports generating separate man pages for subcommands, which doesn't work well with the existing clap_complete_command API, this is blocked until there's a way to generate a single man page (related: clap-rs/clap#3365) which is closer to how the existing shell completions work.

@@ -275,6 +286,8 @@ impl ValueEnum for Shell {
Self::Elvish => clap::builder::PossibleValue::new("elvish"),
Self::Fig => clap::builder::PossibleValue::new("fig"),
Self::Fish => clap::builder::PossibleValue::new("fish"),
#[cfg(feature = "man-page")]
Self::ManPage => clap::builder::PossibleValue::new("man"),
Copy link
Owner Author

Choose a reason for hiding this comment

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

I'm torn on what this should be, for example:

Suggested change
Self::ManPage => clap::builder::PossibleValue::new("man"),
Self::ManPage => clap::builder::PossibleValue::new("man-page"),

Comment on lines +314 to +324
if cfg!(feature = "man-page") {
assert_eq!(
names,
vec!["bash", "elvish", "fig", "fish", "man", "powershell", "zsh"],
);
} else {
assert_eq!(
names,
vec!["bash", "elvish", "fig", "fish", "powershell", "zsh"],
);
}
Copy link
Owner Author

Choose a reason for hiding this comment

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

We should make this scale better for when we add more features in the future.

@nihaals
Copy link
Owner Author

nihaals commented Nov 23, 2022

For people who want to customise their man pages more, like providing a date, we should also make it easy for lib users to special case when the user chooses man page generation, where they can access a more specific API, which would also make it easy to generate separate man pages for each subcommand (clap-rs/clap#3365 (comment), clap-rs/clap#3603). This could also be used as a way to provide man page generation before clap_mangen supports generating a single man page including subcommands.

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.

Add man page support
1 participant