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