[snowpatch] [PATCH] args: Fix (-v | --version)

Russell Currey ruscur at russell.cc
Mon Jul 18 08:22:55 AEST 2016


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 at 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())
         .unwrap_or_else(|e| e.exit());
 
     let settings = settings::parse(args.arg_config_file);
-- 
2.9.0



More information about the snowpatch mailing list