-
Notifications
You must be signed in to change notification settings - Fork 9
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
Man gen #6
Man gen #6
Changes from 11 commits
543693d
4f713cc
dd7700e
5e9ac9d
2a712d9
653436c
51d7dac
adbcf38
c99518c
a85cdb6
77e75bb
1ea4ef2
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
extern crate man; | ||
|
||
use man::Man; | ||
|
||
fn main() { | ||
let msg = Man::new("auth-service") | ||
.description("authorize & authenticate members") | ||
.argument("path".into()) | ||
.environment( | ||
"PORT".into(), | ||
None, | ||
Some("The network port to listen to.".into()), | ||
) | ||
.flag( | ||
Some("-h".into()), | ||
Some("--help".into()), | ||
Some("Prints help information.".into()), | ||
) | ||
.flag( | ||
Some("-V".into()), | ||
Some("--version".into()), | ||
Some("Prints version information.".into()), | ||
) | ||
.flag( | ||
Some("-v".into()), | ||
Some("--verbosity".into()), | ||
Some("Pass multiple times to print more information.".into()), | ||
) | ||
.option( | ||
Some("-a".into()), | ||
Some("--address".into()), | ||
Some("The network address to listen to.".into()), | ||
"address".into(), | ||
Some("127.0.0.1".into()), | ||
) | ||
.option( | ||
Some("-p".into()), | ||
Some("--port".into()), | ||
Some("The network port to listen to.".into()), | ||
"port".into(), | ||
None, | ||
) | ||
.author("Alice Person", Some("[email protected]".into())) | ||
.author("Bob Human", Some("[email protected]".into())) | ||
.render(); | ||
// .option(Some("-o"), Some("--output"), "output", None, "Output file"); | ||
|
||
println!("{}", msg); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,12 @@ | |
#![cfg_attr(test, deny(warnings))] | ||
|
||
extern crate clap; | ||
extern crate roff; | ||
|
||
mod man; | ||
|
||
use clap::{App, Arg, ArgSettings}; | ||
pub use man::*; | ||
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. I'd only expose some very carefully selected items. 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. I think if we can get #9 to land, this will also be solved. For now it mostly enforces the same behavior we'd have as putting everything in |
||
|
||
/// Describe an argument or option | ||
#[derive(Debug)] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/// An author entry. | ||
#[derive(Debug)] | ||
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. You can probably also derive Clone. Not necessary right now but you're not using Debug, too 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. Good point! |
||
pub struct Author { | ||
pub(crate) name: String, | ||
pub(crate) email: Option<String>, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/// Command line environment variable representation. | ||
#[derive(Debug)] | ||
pub struct Env { | ||
pub(crate) name: String, | ||
pub(crate) default: Option<String>, | ||
pub(crate) description: Option<String>, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/// Command line flag representation. | ||
#[derive(Debug)] | ||
pub struct Flag { | ||
pub(crate) short: Option<String>, | ||
pub(crate) long: Option<String>, | ||
pub(crate) description: Option<String>, | ||
} |
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 hate that you don't put empty lines around code blocks. Just so you know. :P
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.
Thanks for sharing; your comment has been noted 😛
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.
As a side note: I'll happily switch to whichever style is conventional the moment
rustfmt
is able to do so automatically. Can't be bothered to otherwise :PThere 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.
brb, doing
cargo new mdfmt