Message ID | 20160717222255.20803-1-ruscur@russell.cc |
---|---|
State | Changes Requested |
Delegated to: | Andrew Donnellan |
Headers | show |
On 18/07/16 08:22, Russell Currey wrote: > I thought we got this by default with docopt but that's not true. There > is a helper in docopt, though, which is nice. > > Signed-off-by: Russell Currey <ruscur@russell.cc> > --- > src/main.rs | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/main.rs b/src/main.rs > index 9bb2064..1476f75 100644 > --- a/src/main.rs > +++ b/src/main.rs > @@ -246,7 +246,7 @@ fn main() { > log_builder.init().unwrap(); > > let args: Args = Docopt::new(USAGE) > - .and_then(|d| d.decode()) > + .and_then(|d| d.version(env::var("CARGO_PKG_VERSION").ok()).decode()) You need to use the env! macro to capture the value of the variable at compile time. Please send V2. > .unwrap_or_else(|e| e.exit()); > > let settings = settings::parse(args.arg_config_file); >
diff --git a/src/main.rs b/src/main.rs index 9bb2064..1476f75 100644 --- a/src/main.rs +++ b/src/main.rs @@ -246,7 +246,7 @@ fn main() { log_builder.init().unwrap(); let args: Args = Docopt::new(USAGE) - .and_then(|d| d.decode()) + .and_then(|d| d.version(env::var("CARGO_PKG_VERSION").ok()).decode()) .unwrap_or_else(|e| e.exit()); let settings = settings::parse(args.arg_config_file);
I thought we got this by default with docopt but that's not true. There is a helper in docopt, though, which is nice. Signed-off-by: Russell Currey <ruscur@russell.cc> --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)