Skip to content

Instantly share code, notes, and snippets.

@jianingy
Last active September 1, 2016 03:15
Show Gist options
  • Save jianingy/cc8a1eaa0ef09a2fd98274786063d5aa to your computer and use it in GitHub Desktop.
Save jianingy/cc8a1eaa0ef09a2fd98274786063d5aa to your computer and use it in GitHub Desktop.
Global Clap Matches
[package]
name = "tryclap"
version = "0.1.0"
authors = ["Jianing Yang <jianingy.yang@gmail.com>"]
[dependencies]
lazy_static = "0.1.*"
[dependencies.clap]
version = "2"
features = [ "suggestions", "color", "unstable" ]
#[macro_use] extern crate lazy_static;
#[macro_use] extern crate clap;
use clap::ArgMatches;
lazy_static! {
static ref OPTIONS: ArgMatches<'static> = {
clap_app!(
tweezer =>
(version: "0.1.0")
(author: "Jianing Yang <jianingy.yang@gmail.com>")
(about: "naive bayes based spam classifier")
(@arg verbose: -v ... "set verbose mode.")
(@arg val1: --val1 +takes_value "val1")
(@arg val2: --val2 +takes_value "val2")
).get_matches()
};
}
fn main() {
println!("Hello, world!");
func1();
func2();
}
fn func1() {
println!("{:?}", OPTIONS.value_of("val1"));
}
fn func2() {
println!("{:?}", OPTIONS.value_of("val2"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment