Make configuration traits methods non-static

This commit is contained in:
Robert Ignat 2017-06-06 22:36:20 +02:00 committed by Matthias Beyer
parent 7375f3c6ac
commit 52b377eaa1
3 changed files with 8 additions and 8 deletions

View file

@ -388,7 +388,7 @@ version = \"0.3.0\"\
} }
impl<'a> GetConfiguration for MockLinkApp<'a> { impl<'a> GetConfiguration for MockLinkApp<'a> {
fn get_configuration(_: &PathBuf) -> ConfigResult<Configuration> { fn get_configuration(&self, _: &PathBuf) -> ConfigResult<Configuration> {
::toml::de::from_slice(TOML_CONFIG_FILE) ::toml::de::from_slice(TOML_CONFIG_FILE)
.map_err(|_| { .map_err(|_| {
ConfigErrorKind::TOMLParserError.into() ConfigErrorKind::TOMLParserError.into()
@ -398,11 +398,11 @@ version = \"0.3.0\"\
} }
impl<'a> InternalConfiguration for MockLinkApp<'a> { impl<'a> InternalConfiguration for MockLinkApp<'a> {
fn enable_hooks() -> bool { fn enable_hooks(&self) -> bool {
false false
} }
fn enable_logging() -> bool { fn enable_logging(&self) -> bool {
false false
} }
} }

View file

@ -216,7 +216,7 @@ pub trait GetConfiguration {
/// ///
/// Default implementation tests several variants for the config file path and uses the first /// Default implementation tests several variants for the config file path and uses the first
/// one which works. /// one which works.
fn get_configuration(rtp: &PathBuf) -> Result<Configuration> { fn get_configuration(&self, rtp: &PathBuf) -> Result<Configuration> {
use std::env; use std::env;
use std::fs::File; use std::fs::File;
use std::io::Read; use std::io::Read;
@ -280,11 +280,11 @@ pub trait GetConfiguration {
impl<'a> GetConfiguration for App<'a, 'a> {} impl<'a> GetConfiguration for App<'a, 'a> {}
pub trait InternalConfiguration { pub trait InternalConfiguration {
fn enable_hooks() -> bool { fn enable_hooks(&self) -> bool {
true true
} }
fn enable_logging() -> bool { fn enable_logging(&self) -> bool {
true true
} }
} }

View file

@ -75,7 +75,7 @@ impl<'a> Runtime<'a> {
let is_verbose = matches.is_present("verbosity"); let is_verbose = matches.is_present("verbosity");
let colored = !matches.is_present("no-color-output"); let colored = !matches.is_present("no-color-output");
if C::enable_logging() { if cli_app.enable_logging() {
Runtime::init_logger(is_debugging, is_verbose, colored); Runtime::init_logger(is_debugging, is_verbose, colored);
} }
@ -112,7 +112,7 @@ impl<'a> Runtime<'a> {
debug!("Store path = {:?}", storepath); debug!("Store path = {:?}", storepath);
debug!("Config path = {:?}", configpath); debug!("Config path = {:?}", configpath);
let cfg = match C::get_configuration(&configpath) { let cfg = match cli_app.get_configuration(&configpath) {
Err(e) => if e.err_type() != ConfigErrorKind::NoConfigFileFound { Err(e) => if e.err_type() != ConfigErrorKind::NoConfigFileFound {
return Err(RuntimeErrorKind::Instantiate.into_error_with_cause(Box::new(e))); return Err(RuntimeErrorKind::Instantiate.into_error_with_cause(Box::new(e)));
} else { } else {