Fix imag-tag::* for new StoreId interface

This commit is contained in:
Matthias Beyer 2016-08-26 15:12:06 +02:00
parent 3cf8a55185
commit cd5d162882

View file

@ -10,14 +10,15 @@ extern crate libimagentrytag;
extern crate libimagerror; extern crate libimagerror;
use std::process::exit; use std::process::exit;
use std::path::PathBuf;
use libimagrt::runtime::Runtime; use libimagrt::runtime::Runtime;
use libimagrt::setup::generate_runtime_setup; use libimagrt::setup::generate_runtime_setup;
use libimagentrytag::tagable::Tagable; use libimagentrytag::tagable::Tagable;
use libimagentrytag::tag::Tag; use libimagentrytag::tag::Tag;
use libimagstore::storeid::build_entry_path;
use libimagerror::trace::{trace_error, trace_error_exit}; use libimagerror::trace::{trace_error, trace_error_exit};
use libimagentrytag::ui::{get_add_tags, get_remove_tags}; use libimagentrytag::ui::{get_add_tags, get_remove_tags};
use libimagstore::storeid::StoreId;
mod ui; mod ui;
@ -34,11 +35,13 @@ fn main() {
.subcommand_name() .subcommand_name()
.map_or_else( .map_or_else(
|| { || {
let id = PathBuf::from(id);
let add = get_add_tags(rt.cli()); let add = get_add_tags(rt.cli());
let rem = get_remove_tags(rt.cli()); let rem = get_remove_tags(rt.cli());
alter(&rt, id, add, rem); alter(&rt, id, add, rem);
}, },
|name| { |name| {
let id = PathBuf::from(id);
debug!("Call: {}", name); debug!("Call: {}", name);
match name { match name {
"list" => list(id, &rt), "list" => list(id, &rt),
@ -50,9 +53,9 @@ fn main() {
}); });
} }
fn alter(rt: &Runtime, id: &str, add: Option<Vec<Tag>>, rem: Option<Vec<Tag>>) { fn alter(rt: &Runtime, id: PathBuf, add: Option<Vec<Tag>>, rem: Option<Vec<Tag>>) {
let path = { let path = {
match build_entry_path(rt.store(), id) { match StoreId::new(Some(rt.store().path().clone()), id) {
Err(e) => trace_error_exit(&e, 1), Err(e) => trace_error_exit(&e, 1),
Ok(s) => s, Ok(s) => s,
} }
@ -91,12 +94,10 @@ fn alter(rt: &Runtime, id: &str, add: Option<Vec<Tag>>, rem: Option<Vec<Tag>>) {
} }
} }
fn list(id: &str, rt: &Runtime) { fn list(id: PathBuf, rt: &Runtime) {
let path = { let path = match StoreId::new(Some(rt.store().path().clone()), id) {
match build_entry_path(rt.store(), id) { Err(e) => trace_error_exit(&e, 1),
Err(e) => trace_error_exit(&e, 1), Ok(s) => s,
Ok(s) => s,
}
}; };
debug!("path = {:?}", path); debug!("path = {:?}", path);
@ -108,8 +109,7 @@ fn list(id: &str, rt: &Runtime) {
}, },
Err(e) => { Err(e) => {
debug!("Could not get '{:?}' => {:?}", id, path); warn!("Could not get entry '{:?}'", path);
warn!("Could not get entry '{}'", id);
trace_error_exit(&e, 1); trace_error_exit(&e, 1);
}, },
}; };