Skip to content

Instantly share code, notes, and snippets.

@jcdyer
Created June 29, 2017 23:46
Show Gist options
  • Save jcdyer/c92033fd835b1900dd501a373f056d63 to your computer and use it in GitHub Desktop.
Save jcdyer/c92033fd835b1900dd501a373f056d63 to your computer and use it in GitHub Desktop.
Hello command line
[package]
name = "hello"
version = "0.1.0"
authors = ["J. Cliff Dyer <jcd@sdf.org>"]
[dependencies]
clap = "~2"
extern crate clap;
use clap::{App, Arg};
fn main() {
let matches = App::new("Hello World")
//.author("Triangle Rustaceans")
//.about("Say hello.")
//.version("1.0")
.arg(Arg::with_name("name")
.short("n")
.long("name")
//.value_name("NAME")
//.help("Who do you want to greet?")
.takes_value(true))
.get_matches();
let greetee = matches.value_of("name").unwrap_or("world");
println!("Hello {}!", greetee);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment