summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main.rs24
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() {