[snowpatch] [PATCH] args: Fix (-v | --version)
Andrew Donnellan
andrew.donnellan at au1.ibm.com
Mon Jul 18 10:44:43 AEST 2016
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 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())
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);
>
--
Andrew Donnellan OzLabs, ADL Canberra
andrew.donnellan at au1.ibm.com IBM Australia Limited
More information about the snowpatch
mailing list