diff options
author | Caleb Bassi <calebjbassi@gmail.com> | 2019-02-15 03:30:40 -0800 |
---|---|---|
committer | Caleb Bassi <calebjbassi@gmail.com> | 2019-02-15 05:20:33 -0800 |
commit | 8a48989e8a69568e850a18f5686810b7adf92b3d (patch) | |
tree | 87f7c4fd996965d1e06cf29c3be14464ecebc8d2 /src/main.rs | |
parent | 07f03353e27eb7df9a6e0f6457dd79bfd6ff4dac (diff) |
Replace clap with structopt for argument parsing
- structopt is built on top of clap and provides a convenient layer for configuring cli args
- it also comes built in with `-V, --version` and `-h, --help`
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/main.rs b/src/main.rs index 4627a29..2b07eb1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,16 +1,14 @@ #[macro_use] -extern crate clap; -#[macro_use] extern crate lazy_static; #[macro_use] extern crate serde_derive; -extern crate toml; +extern crate structopt; extern crate xdg; mod joshuto; -use std::env; use std::path::PathBuf; +use structopt::StructOpt; use joshuto::config::{JoshutoConfig, JoshutoKeymap}; @@ -37,14 +35,11 @@ lazy_static! { }; } +#[derive(StructOpt, Debug)] +pub struct Args {} + fn main() { - let args: Vec<String> = env::args().collect(); - for arg in &args { - if arg.as_str() == "-v" { - println!("{}", crate_version!()); - return; - } - } + let _ = Args::from_args(); let config = JoshutoConfig::get_config(); let keymap = JoshutoKeymap::get_config(); |