diff options
Diffstat (limited to 'bin/domain/imag-contact/src/ui.rs')
-rw-r--r-- | bin/domain/imag-contact/src/ui.rs | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/bin/domain/imag-contact/src/ui.rs b/bin/domain/imag-contact/src/ui.rs index f60fd17d..4767b175 100644 --- a/bin/domain/imag-contact/src/ui.rs +++ b/bin/domain/imag-contact/src/ui.rs @@ -17,7 +17,13 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // -use clap::{Arg, App, SubCommand}; +use std::path::PathBuf; + +use clap::{Arg, ArgMatches, App, SubCommand}; +use failure::Fallible as Result; + +use libimagstore::storeid::StoreId; +use libimagrt::runtime::IdPathProvider; pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { app @@ -76,13 +82,13 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { .subcommand(SubCommand::with_name("show") .about("Show contact") .version("0.1") - .arg(Arg::with_name("hash") + .arg(Arg::with_name("ids") .index(1) .takes_value(true) - .required(true) - .multiple(false) - .value_name("HASH") - .help("Show the contact pointed to by this reference hash")) + .required(false) + .multiple(true) + .value_name("ID") + .help("Show the contact pointed to by this reference hash or by the full store id")) .arg(Arg::with_name("format") .long("format") .takes_value(true) @@ -207,3 +213,16 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { .help("Don't track the new vcf file if one is created.")) ) } + +pub struct PathProvider; +impl IdPathProvider for PathProvider { + fn get_ids(matches: &ArgMatches) -> Result<Option<Vec<StoreId>>> { + if let Some(ids) = matches.values_of("ids") { + ids.map(|i| StoreId::new(PathBuf::from(i))) + .collect::<Result<Vec<StoreId>>>() + .map(Some) + } else { + Ok(None) + } + } +} |