Replace matching with command chaining
This commit is contained in:
parent
7d1d41884c
commit
a9135a80fb
1 changed files with 6 additions and 7 deletions
|
@ -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])
|
||||||
},
|
})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue