Merge pull request #741 from matthiasbeyer/libimagentryselect-libimaginteraction-merge
Move code from libimagentryselect to libimaginteraction
This commit is contained in:
commit
c35b08b4dc
10 changed files with 20 additions and 83 deletions
|
@ -26,9 +26,6 @@ path = "../libimagentrylist"
|
|||
[dependencies.libimagentrymarkdown]
|
||||
path = "../libimagentrymarkdown"
|
||||
|
||||
[dependencies.libimagentryselect]
|
||||
path = "../libimagentryselect"
|
||||
|
||||
[dependencies.libimagentrytag]
|
||||
path = "../libimagentrytag"
|
||||
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
[package]
|
||||
name = "libimagentryselect"
|
||||
version = "0.2.0"
|
||||
authors = ["Matthias Beyer <mail@beyermatthias.de>"]
|
||||
|
||||
[dependencies]
|
||||
clap = "2.*"
|
||||
log = "0.3"
|
||||
interactor = "0.1"
|
||||
|
||||
[dependencies.libimagstore]
|
||||
path = "../libimagstore"
|
||||
|
||||
[dependencies.libimagerror]
|
||||
path = "../libimagerror"
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
# libimagentryselect
|
||||
|
||||
Small library crate for asking the user to _select_ one or more entries out of
|
||||
a list of entries.
|
||||
|
||||
Not much functionality, yet.
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
generate_error_module!(
|
||||
generate_error_types!(EntrySelectError, EntrySelectErrorKind,
|
||||
CLIError => "Error on commandline",
|
||||
IdMissingError => "Commandline: ID missing",
|
||||
StoreIdParsingError => "Error while parsing StoreId",
|
||||
IdSelectingError => "Error while selecting id"
|
||||
);
|
||||
);
|
||||
|
||||
pub use self::error::EntrySelectError;
|
||||
pub use self::error::EntrySelectErrorKind;
|
||||
pub use self::error::MapErrInto;
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
#![deny(
|
||||
non_camel_case_types,
|
||||
non_snake_case,
|
||||
path_statements,
|
||||
trivial_numeric_casts,
|
||||
unstable_features,
|
||||
unused_allocation,
|
||||
unused_import_braces,
|
||||
unused_imports,
|
||||
unused_mut,
|
||||
unused_qualifications,
|
||||
while_true,
|
||||
)]
|
||||
|
||||
extern crate clap;
|
||||
extern crate log;
|
||||
extern crate interactor;
|
||||
|
||||
extern crate libimagstore;
|
||||
#[macro_use]
|
||||
extern crate libimagerror;
|
||||
|
||||
pub mod error;
|
||||
pub mod result;
|
||||
pub mod ui;
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
use std::result::Result as RResult;
|
||||
|
||||
use error::EntrySelectError;
|
||||
|
||||
pub type Result<T> = RResult<T, EntrySelectError>;
|
||||
|
|
@ -4,12 +4,13 @@ version = "0.2.0"
|
|||
authors = ["Matthias Beyer <mail@beyermatthias.de>"]
|
||||
|
||||
[dependencies]
|
||||
spinner = "0.4"
|
||||
interactor = "0.1"
|
||||
log = "0.3"
|
||||
ansi_term = "0.7.2"
|
||||
regex = "0.1"
|
||||
clap = "2.*"
|
||||
interactor = "0.1"
|
||||
lazy_static = "0.1.15"
|
||||
log = "0.3"
|
||||
regex = "0.1"
|
||||
spinner = "0.4"
|
||||
|
||||
[dependencies.libimagstore]
|
||||
path = "../libimagstore"
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
generate_error_module!(
|
||||
generate_error_types!(InteractionError, InteractionErrorKind,
|
||||
Unknown => "Unknown Error"
|
||||
Unknown => "Unknown Error",
|
||||
CLIError => "Error on commandline",
|
||||
IdMissingError => "Commandline: ID missing",
|
||||
StoreIdParsingError => "Error while parsing StoreId",
|
||||
IdSelectingError => "Error while selecting id"
|
||||
);
|
||||
);
|
||||
|
||||
pub use self::error::InteractionError;
|
||||
pub use self::error::InteractionErrorKind;
|
||||
pub use self::error::MapErrInto;
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ extern crate interactor;
|
|||
extern crate ansi_term;
|
||||
#[macro_use] extern crate lazy_static;
|
||||
extern crate regex;
|
||||
extern crate clap;
|
||||
|
||||
extern crate libimagentryfilter;
|
||||
extern crate libimagstore;
|
||||
|
@ -28,4 +29,5 @@ pub mod ask;
|
|||
pub mod error;
|
||||
pub mod filter;
|
||||
pub mod result;
|
||||
pub mod ui;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ use libimagerror::into::IntoError;
|
|||
|
||||
use result::Result;
|
||||
use error::MapErrInto;
|
||||
use error::EntrySelectErrorKind as ESEK;
|
||||
use error::InteractionErrorKind as IEK;
|
||||
|
||||
pub fn id_argument<'a, 'b>() -> Arg<'a, 'b> {
|
||||
Arg::with_name(id_argument_name())
|
||||
|
@ -33,14 +33,14 @@ pub fn id_argument_long() -> &'static str {
|
|||
pub fn get_id(matches: &ArgMatches) -> Result<Vec<StoreId>> {
|
||||
matches
|
||||
.values_of(id_argument_name())
|
||||
.ok_or(ESEK::IdMissingError.into_error())
|
||||
.map_err_into(ESEK::CLIError)
|
||||
.ok_or(IEK::IdMissingError.into_error())
|
||||
.map_err_into(IEK::CLIError)
|
||||
.and_then(|vals| {
|
||||
vals.into_iter()
|
||||
.fold(Ok(vec![]), |acc, elem| {
|
||||
acc.and_then(|mut v| {
|
||||
let elem = StoreId::new_baseless(PathBuf::from(String::from(elem)));
|
||||
let elem = try!(elem.map_err_into(ESEK::StoreIdParsingError));
|
||||
let elem = try!(elem.map_err_into(IEK::StoreIdParsingError));
|
||||
v.push(elem);
|
||||
Ok(v)
|
||||
})
|
||||
|
@ -51,12 +51,12 @@ pub fn get_id(matches: &ArgMatches) -> Result<Vec<StoreId>> {
|
|||
pub fn get_or_select_id(matches: &ArgMatches, store_path: &PathBuf) -> Result<Vec<StoreId>> {
|
||||
use interactor::{pick_file, default_menu_cmd};
|
||||
|
||||
match get_id(matches).map_err_into(ESEK::IdSelectingError) {
|
||||
match get_id(matches).map_err_into(IEK::IdSelectingError) {
|
||||
Ok(v) => Ok(v),
|
||||
Err(_) => {
|
||||
let path = store_path.clone();
|
||||
let p = try!(pick_file(default_menu_cmd, path).map_err_into(ESEK::IdSelectingError));
|
||||
let id = try!(StoreId::new_baseless(p).map_err_into(ESEK::StoreIdParsingError));
|
||||
let p = try!(pick_file(default_menu_cmd, path).map_err_into(IEK::IdSelectingError));
|
||||
let id = try!(StoreId::new_baseless(p).map_err_into(IEK::StoreIdParsingError));
|
||||
Ok(vec![id])
|
||||
},
|
||||
}
|
Loading…
Reference in a new issue