Add config fetching function for Ref::get_path() parameter
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
34d9f3429f
commit
27c0a30494
2 changed files with 25 additions and 2 deletions
|
@ -22,7 +22,8 @@ is-it-maintained-open-issues = { repository = "matthiasbeyer/imag" }
|
|||
maintenance = { status = "actively-developed" }
|
||||
|
||||
[dependencies]
|
||||
log = "0.4.0"
|
||||
log = "0.4.0"
|
||||
failure = "0.1"
|
||||
|
||||
libimagstore = { version = "0.10.0", path = "../../../lib/core/libimagstore" }
|
||||
libimagrt = { version = "0.10.0", path = "../../../lib/core/libimagrt" }
|
||||
|
@ -36,3 +37,8 @@ version = "^2.29"
|
|||
default-features = false
|
||||
features = ["color", "suggestions", "wrap_help"]
|
||||
|
||||
[dependencies.toml-query]
|
||||
version = "0.8"
|
||||
default-features = false
|
||||
features = ["typed"]
|
||||
|
||||
|
|
|
@ -35,7 +35,9 @@
|
|||
)]
|
||||
|
||||
#[macro_use] extern crate log;
|
||||
#[macro_use] extern crate failure;
|
||||
extern crate clap;
|
||||
extern crate toml_query;
|
||||
|
||||
extern crate libimagstore;
|
||||
#[macro_use] extern crate libimagrt;
|
||||
|
@ -50,6 +52,8 @@ use ui::build_ui;
|
|||
use std::process::exit;
|
||||
use std::io::Write;
|
||||
|
||||
use failure::Fallible as Result;
|
||||
|
||||
use libimagerror::trace::MapErrTrace;
|
||||
use libimagerror::exit::ExitUnwrap;
|
||||
use libimagrt::setup::generate_runtime_setup;
|
||||
|
@ -58,6 +62,7 @@ use libimagentryref::reference::Ref;
|
|||
use libimagentryref::reference::MutRef;
|
||||
use libimagentryref::reference::RefFassade;
|
||||
use libimagentryref::hasher::default::DefaultHasher;
|
||||
use libimagentryref::reference::Config as RefConfig;
|
||||
|
||||
fn main() {
|
||||
let version = make_imag_version!();
|
||||
|
@ -87,6 +92,7 @@ fn main() {
|
|||
fn deref(rt: &Runtime) {
|
||||
let cmd = rt.cli().subcommand_matches("deref").unwrap();
|
||||
let ids = rt.ids::<::ui::PathProvider>().map_err_trace_exit_unwrap();
|
||||
let cfg = get_ref_config(&rt).map_err_trace_exit_unwrap();
|
||||
let out = rt.stdout();
|
||||
let mut outlock = out.lock();
|
||||
|
||||
|
@ -96,7 +102,7 @@ fn deref(rt: &Runtime) {
|
|||
Some(entry) => {
|
||||
entry
|
||||
.as_ref_with_hasher::<DefaultHasher>()
|
||||
.get_path()
|
||||
.get_path(&cfg)
|
||||
.map_err_trace_exit_unwrap()
|
||||
.to_str()
|
||||
.ok_or_else(|| {
|
||||
|
@ -157,3 +163,14 @@ fn create(rt: &Runtime) {
|
|||
unimplemented!()
|
||||
}
|
||||
|
||||
fn get_ref_config(rt: &Runtime) -> Result<RefConfig> {
|
||||
use toml_query::read::TomlValueReadExt;
|
||||
|
||||
let setting_name = "ref.basepathes";
|
||||
|
||||
rt.config()
|
||||
.ok_or_else(|| format_err!("No configuration, cannot find collection name for ref collection"))?
|
||||
.read_deserialized::<RefConfig>(setting_name)?
|
||||
.ok_or_else(|| format_err!("Setting missing: {}", setting_name))
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue