Skip to content
Snippets Groups Projects
Commit 4a2f7def authored by Eduardo Trujillo's avatar Eduardo Trujillo
Browse files

feat(cli): Add figment support

parent b0b855f2
No related branches found
No related tags found
Loading
Pipeline #143 passed
...@@ -2,7 +2,7 @@ use std::path::PathBuf; ...@@ -2,7 +2,7 @@ use std::path::PathBuf;
use clap::{Clap, IntoApp}; use clap::{Clap, IntoApp};
use log::LevelFilter; use log::LevelFilter;
use serde::de::DeserializeOwned; use serde::{de::DeserializeOwned, Serialize};
use thiserror::Error; use thiserror::Error;
use crate::config; use crate::config;
...@@ -45,13 +45,13 @@ pub trait AppOpts: Clap { ...@@ -45,13 +45,13 @@ pub trait AppOpts: Clap {
} }
} }
pub trait ConfigurableAppOpts<C: DeserializeOwned>: AppOpts { pub trait ConfigurableAppOpts<C: DeserializeOwned + Default + Serialize>: AppOpts {
fn try_init_with_config() -> Result<(Self, C), CliError> { fn try_init_with_config() -> Result<(Self, C), CliError> {
let opts = Self::try_init()?; let opts = Self::try_init()?;
let app = <Self as IntoApp>::into_app(); let app = <Self as IntoApp>::into_app();
let conf = config::from_default_paths(app.get_name(), &opts.get_additional_config_paths()) let conf = config::from_defaults(app.get_name(), &opts.get_additional_config_paths())
.map_err(CliError::Config)?; .map_err(CliError::Config)?;
Ok((opts, conf)) Ok((opts, conf))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment