diff options
author | syn <isaqtm@gmail.com> | 2021-03-12 10:15:01 +0300 |
---|---|---|
committer | syn <isaqtm@gmail.com> | 2021-03-12 10:15:01 +0300 |
commit | 850510d9da9500de5652214711ec2b47e237fbda (patch) | |
tree | 74d52dad0076786fc94eec307ffe1c176f809d06 | |
parent | 81d318ab62b4742eaf2b8f6a1e5270cf2f76f8b3 (diff) | |
download | evr-master.tar.gz |
-rw-r--r-- | src/main.rs | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/main.rs b/src/main.rs index c85b30a..4d7b909 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ extern crate lazy_static; -use clap::{App, AppSettings, Arg, SubCommand}; +use clap::{App, AppSettings, Arg}; use env_logger; use log::error; @@ -15,7 +15,6 @@ fn main() { .author("syn") .setting(AppSettings::ColoredHelp) .setting(AppSettings::UnifiedHelpMessage) - .subcommand(SubCommand::with_name("where")) .arg( Arg::with_name("src") .required(true) @@ -34,6 +33,12 @@ fn main() { .long("mem") .help("show mem usage (rss)"), ) + .arg( + Arg::with_name("where") + .short("w") + .long("where") + .help("only print executable location. error if does not exist"), + ) .get_matches(); env_logger::builder().format_timestamp(None).init(); @@ -48,15 +53,16 @@ fn main() { } }; - match matches.subcommand() { - ("where", Some(_submodule)) => { - match backends::get_binary_by_filename(src_path.as_ref()) { - Ok(path) => eprintln!("{}", path.display()), - Err(e) => error!("No binary: {}", e), + if matches.is_present("where") { + match backends::get_binary_by_filename(src_path.as_ref()) { + Ok(path) => if path.exists() { + println!("{}", path.display()) + } else { + error!("File should be located at '{}', when you build it", path.display()) } - return; + Err(e) => error!("No binary: {}", e), } - _ => {} + return; } if src_path.exists() { |