Add store entry path builder helper

This commit is contained in:
Matthias Beyer 2016-01-29 16:50:52 +01:00
parent ddd54e03ad
commit caee76650d

View file

@ -1,12 +1,27 @@
use std::collections::BTreeMap;
use std::path::PathBuf;
use std::str::Split;
use clap::ArgMatches;
use toml::Value;
use libimagstore::store::EntryHeader;
use libimagrt::runtime::Runtime;
use libimagutil::key_value_split::IntoKeyValue;
pub fn build_entry_path(rt: &Runtime, path_elem: &str) -> PathBuf {
debug!("Building path...");
let mut path = rt.store().path().clone();
if path_elem.chars().next() == Some('/') {
path.push(&path_elem[1..path_elem.len()]);
} else {
path.push(path_elem);
}
path
}
pub fn build_toml_header(matches: &ArgMatches, header: EntryHeader) -> EntryHeader {
debug!("Building header from cli spec");
if let Some(headerspecs) = matches.values_of("header") {