Skip to content

Commit

Permalink
rust: docopt → clap
Browse files Browse the repository at this point in the history
It's more popular and nicer.

Signed-off-by: Igor Gnatenko <[email protected]>
  • Loading branch information
Igor Gnatenko authored and cgwalters committed Jan 10, 2018
1 parent c14cbbe commit 7093240
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
12 changes: 3 additions & 9 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,11 @@ version = "0.1.0"
authors = ["Colin Walters <[email protected]>"]

[dependencies]
# git2 = "0.4"
openssl = "0.7"
docopt = "0.6"
clap = "2"
git2 = "0.6.11"
openssl = "0.9"
rustc-serialize = "0.3"

[dependencies.git2]
path = "/home/walters/src/github/alexcrichton/git2-rs"

[dependencies.libgit2-sys]
path = "/home/walters/src/github/alexcrichton/git2-rs/libgit2-sys"

[[bin]]
name = "git-rustevtag"
test = false
Expand Down
28 changes: 13 additions & 15 deletions rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

extern crate docopt;
#[macro_use]
extern crate clap;
extern crate git2;
extern crate openssl;
extern crate rustc_serialize;
Expand All @@ -15,16 +16,14 @@ use std::process::Command;
use std::io::Write;
use git2::{Commit, Error, Object, ObjectType, Oid, Repository, Submodule, Tree};
use std::error::Error as StdError;
use docopt::Docopt;
#[allow(unused_imports)]
use openssl::crypto::hash::Hasher;
use rustc_serialize::hex::ToHex;

const EVTAG_SHA512: &'static str = "Git-EVTag-v0-SHA512:";

#[derive(RustcDecodable)]
struct Args {
arg_tagname: String,
struct Args<'a> {
arg_tagname: &'a str,
flag_no_signature: bool,
}

Expand Down Expand Up @@ -156,17 +155,16 @@ fn run(args: &Args) -> Result<(), Error> {
}

fn main() {
const USAGE: &'static str = "
usage:
git-evtag verify [-n] <tagname>
Options:
-n, --no-signature Do not verify GPG signature
";
let matches = clap_app!(git_evtag =>
(@arg no_signature: -n --no-signature "Do not verify GPG signature")
(@arg TAGNAME: +required "Tag name")
).get_matches();

let args = Args {
flag_no_signature: matches.is_present("no_signature"),
arg_tagname: matches.value_of("TAGNAME").unwrap(),
};

let args = Docopt::new(USAGE)
.and_then(|d| d.decode())
.unwrap_or_else(|e| e.exit());
match run(&args) {
Ok(()) => {}
Err(e) => println!("error: {}", e),
Expand Down

0 comments on commit 7093240

Please sign in to comment.