-
Notifications
You must be signed in to change notification settings - Fork 89
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
Expose HelpMessage and allow for custom help switches #53
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -207,6 +207,17 @@ impl<T: SubCommand> SubCommands for T { | |
const COMMANDS: &'static [&'static CommandInfo] = &[T::COMMAND]; | ||
} | ||
|
||
/// A `HelpMessage` implementation that provides a help/usage message corresponding | ||
/// to the type's `FromArgs` implementation. | ||
pub trait HelpMessage: FromArgs { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why an additional trait instead of adding a method to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The help message only exists for |
||
/// The help/usage message. | ||
/// | ||
/// The first argument `command_name` is the identifier for the current | ||
/// command, treating each segment as space-separated. This will be used | ||
/// in the help message. | ||
fn help_message(command_name: &[&str]) -> String; | ||
} | ||
|
||
/// Information to display to the user about why a `FromArgs` construction exited early. | ||
/// | ||
/// This can occur due to either failed parsing or a flag like `--help`. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stylistically, I think flipping this to "enable_help" reads a bit better. That avoids devs having to mentally parse expressions like
if !disable_help { ... }
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I chose
disable_help
because as a dev I usually assume optional boolean flags to default tofalse
, but I can change that if you want