Add store entry path builder helper
This commit is contained in:
parent
ddd54e03ad
commit
caee76650d
1 changed files with 15 additions and 0 deletions
|
@ -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") {
|
||||
|
|
Loading…
Reference in a new issue