Replace matching with command chaining

This commit is contained in:
Matthias Beyer 2018-01-04 20:26:01 +01:00
parent 7d1d41884c
commit a9135a80fb

View file

@ -70,14 +70,13 @@ pub fn get_id(matches: &ArgMatches) -> Result<Vec<StoreId>> {
pub fn get_or_select_id(matches: &ArgMatches, store_path: &PathBuf) -> Result<Vec<StoreId>> { pub fn get_or_select_id(matches: &ArgMatches, store_path: &PathBuf) -> Result<Vec<StoreId>> {
use interactor::{pick_file, default_menu_cmd}; use interactor::{pick_file, default_menu_cmd};
match get_id(matches).chain_err(|| IEK::IdSelectingError) { get_id(matches)
Ok(v) => Ok(v), .chain_err(|| IEK::IdSelectingError)
Err(_) => { .or_else(|_| {
let path = store_path.clone(); let path = store_path.clone();
let p = pick_file(default_menu_cmd, path).chain_err(|| IEK::IdSelectingError)?; let p = pick_file(default_menu_cmd, path).chain_err(|| IEK::IdSelectingError)?;
let id = StoreId::new_baseless(p).chain_err(|| IEK::StoreIdParsingError)?; let id = StoreId::new_baseless(p).chain_err(|| IEK::StoreIdParsingError)?;
Ok(vec![id]) Ok(vec![id])
}, })
}
} }