Merge pull request #682 from matthiasbeyer/rewrite-storeid-type-cleanup-libimagentryview
libimagentryview cleanup
This commit is contained in:
commit
ae280f178c
4 changed files with 1 additions and 67 deletions
|
@ -30,7 +30,6 @@ use std::path::PathBuf;
|
||||||
use libimagrt::setup::generate_runtime_setup;
|
use libimagrt::setup::generate_runtime_setup;
|
||||||
use libimagerror::trace::trace_error_exit;
|
use libimagerror::trace::trace_error_exit;
|
||||||
use libimagentryview::builtin::stdout::StdoutViewer;
|
use libimagentryview::builtin::stdout::StdoutViewer;
|
||||||
use libimagentryview::builtin::versions::VersionsViewer;
|
|
||||||
use libimagentryview::viewer::Viewer;
|
use libimagentryview::viewer::Viewer;
|
||||||
|
|
||||||
mod ui;
|
mod ui;
|
||||||
|
@ -66,9 +65,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let res = if rt.cli().is_present("versions") {
|
let res = {
|
||||||
VersionsViewer::new(rt.store()).view_entry(&entry)
|
|
||||||
} else {
|
|
||||||
if scmd.is_present("view-in-stdout") {
|
if scmd.is_present("view-in-stdout") {
|
||||||
} else if scmd.is_present("view-in-ui") {
|
} else if scmd.is_present("view-in-ui") {
|
||||||
warn!("Viewing in UI is currently not supported, switch to stdout");
|
warn!("Viewing in UI is currently not supported, switch to stdout");
|
||||||
|
|
|
@ -10,12 +10,6 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
|
||||||
.help("View this entry at this store path")
|
.help("View this entry at this store path")
|
||||||
.value_name("ID"))
|
.value_name("ID"))
|
||||||
|
|
||||||
.arg(Arg::with_name("versions")
|
|
||||||
.long("versions")
|
|
||||||
.takes_value(false)
|
|
||||||
.required(false)
|
|
||||||
.help("Only print available versions for this file"))
|
|
||||||
|
|
||||||
.arg(Arg::with_name("view-header")
|
.arg(Arg::with_name("view-header")
|
||||||
.long("header")
|
.long("header")
|
||||||
.short("h")
|
.short("h")
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
pub mod editor;
|
pub mod editor;
|
||||||
pub mod plain;
|
pub mod plain;
|
||||||
pub mod stdout;
|
pub mod stdout;
|
||||||
pub mod versions;
|
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
use libimagstore::store::Entry;
|
|
||||||
use libimagstore::store::Store;
|
|
||||||
use libimagerror::into::IntoError;
|
|
||||||
|
|
||||||
use viewer::Viewer;
|
|
||||||
use result::Result;
|
|
||||||
use error::ViewErrorKind as VEK;
|
|
||||||
use error::MapErrInto;
|
|
||||||
|
|
||||||
pub struct VersionsViewer<'a> {
|
|
||||||
store: &'a Store,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> VersionsViewer<'a> {
|
|
||||||
|
|
||||||
pub fn new(store: &'a Store) -> VersionsViewer<'a> {
|
|
||||||
VersionsViewer {
|
|
||||||
store: store,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> Viewer for VersionsViewer<'a> {
|
|
||||||
|
|
||||||
fn view_entry(&self, entr: &Entry) -> Result<()> {
|
|
||||||
use glob::glob;
|
|
||||||
|
|
||||||
entr.get_location()
|
|
||||||
.clone()
|
|
||||||
.with_base(self.store.path().clone())
|
|
||||||
.to_str()
|
|
||||||
.map_err_into(VEK::ViewError)
|
|
||||||
.and_then(|s| {
|
|
||||||
s.split("~")
|
|
||||||
.next()
|
|
||||||
.ok_or(VEK::PatternError.into_error())
|
|
||||||
.map(|s| format!("{}~*", s))
|
|
||||||
.and_then(|pat| glob(&pat[..]).map_err(|_| VEK::PatternError.into_error()))
|
|
||||||
.and_then(|paths| {
|
|
||||||
for entry in paths {
|
|
||||||
println!("{}",
|
|
||||||
try!(entry
|
|
||||||
.map_err(|_| VEK::GlobError.into_error()))
|
|
||||||
.file_name()
|
|
||||||
.and_then(|s| s.to_str())
|
|
||||||
.unwrap() // TODO
|
|
||||||
);
|
|
||||||
};
|
|
||||||
Ok(())
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue