From 6ab586708cbc590f2b4f9265c3d07e491105970e Mon Sep 17 00:00:00 2001 From: syn Date: Thu, 11 Mar 2021 20:57:38 +0300 Subject: Add where subcommand --- src/main.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 2ad7991..d1484a4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ extern crate lazy_static; -use clap::{App, AppSettings, Arg}; +use clap::{App, AppSettings, Arg, SubCommand}; use env_logger; use log::error; use std::io::prelude::*; @@ -16,6 +16,7 @@ fn main() { .author("syn") .setting(AppSettings::ColoredHelp) .setting(AppSettings::UnifiedHelpMessage) + .subcommand(SubCommand::with_name("where")) .arg( Arg::with_name("src") .required(true) @@ -48,6 +49,17 @@ 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), + } + return; + } + _ => {} + } + if src_path.exists() { if let Some(backend) = config.get_backend(&src_path) { match backend.run(&src_path) { -- cgit v1.2.1-18-gbd029