From patchwork Mon Jul 18 00:55:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell Currey X-Patchwork-Id: 649295 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rt4VH6Nypz9s5J for ; Mon, 18 Jul 2016 10:55:51 +1000 (AEST) Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3rt4VH4RHGzDqLd for ; Mon, 18 Jul 2016 10:55:51 +1000 (AEST) X-Original-To: snowpatch@lists.ozlabs.org Delivered-To: snowpatch@lists.ozlabs.org Received: from russell.cc (russell.cc [IPv6:2404:9400:2:0:216:3eff:fee0:3370]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3rt4VD6PVrzDqDX for ; Mon, 18 Jul 2016 10:55:48 +1000 (AEST) Received: from snap.au.ibm.com (124-171-160-237.dyn.iinet.net.au [124.171.160.237]) by russell.cc (OpenSMTPD) with ESMTPSA id 6a00f243 TLS version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO; Mon, 18 Jul 2016 00:55:57 +0000 (UTC) From: Russell Currey To: snowpatch@lists.ozlabs.org Date: Mon, 18 Jul 2016 10:55:31 +1000 Message-Id: <20160718005531.27439-1-ruscur@russell.cc> X-Mailer: git-send-email 2.9.0 Subject: [snowpatch] [PATCH] args: Fix (-v | --version) X-BeenThere: snowpatch@lists.ozlabs.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Continuous Integration for patch-based workflows List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Russell Currey MIME-Version: 1.0 Errors-To: snowpatch-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "snowpatch" 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 --- V2: compile time, add prefix --- src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 9bb2064..57fd5ad 100644 --- a/src/main.rs +++ b/src/main.rs @@ -245,8 +245,11 @@ fn main() { } log_builder.init().unwrap(); + let version = format!("{} version {}", + env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION")); + let args: Args = Docopt::new(USAGE) - .and_then(|d| d.decode()) + .and_then(|d| d.version(Some(version)).decode()) .unwrap_or_else(|e| e.exit()); let settings = settings::parse(args.arg_config_file);