diff --git a/config.example.toml b/config.example.toml index 4b2b40e6..3ae12fda 100644 --- a/config.example.toml +++ b/config.example.toml @@ -38,8 +38,5 @@ #[commands] #"Python Environment" = "~/dev/.env/bin/pip install -i https://pypi.python.org/simple -U --upgrade-strategy eager jupyter" -# Output logs -#verbose = true - # Cleanup temporary or old files #cleanup = true diff --git a/src/config.rs b/src/config.rs index 05e35052..0a43d084 100644 --- a/src/config.rs +++ b/src/config.rs @@ -4,7 +4,7 @@ use directories::BaseDirs; use failure::ResultExt; use strum::{EnumIter, EnumString, EnumVariantNames, IntoEnumIterator}; -use log::{debug, error, LevelFilter}; +use log::{debug, LevelFilter}; use pretty_env_logger::formatted_timed_builder; use serde::Deserialize; use shellexpand; @@ -64,7 +64,6 @@ pub struct ConfigFile { yay_arguments: Option, no_retry: Option, run_in_tmux: Option, - verbose: Option, cleanup: Option, only: Option>, } @@ -75,8 +74,8 @@ impl ConfigFile { if !config_path.exists() { write(&config_path, include_str!("../config.example.toml")) .map_err(|e| { - error!( - "Unable to write the example configuration file to {}: {}", + debug!( + "Unable to write the example configuration file to {}: {}. Using blank config.", config_path.display(), e ); @@ -184,18 +183,19 @@ impl Config { /// The function parses the command line arguments and reading the configuration file. pub fn load(base_dirs: &BaseDirs) -> Result { let opt = CommandLineArgs::from_args(); - let config_file = ConfigFile::read(base_dirs)?; let mut builder = formatted_timed_builder(); - if opt.verbose || config_file.verbose.unwrap_or(false) { + if opt.verbose { builder.filter(Some("topgrade"), LevelFilter::Trace); } - let allowed_steps = Self::allowed_steps(&opt, &config_file); - builder.init(); + let config_file = ConfigFile::read(base_dirs).unwrap_or_else(|_| ConfigFile::default()); + + let allowed_steps = Self::allowed_steps(&opt, &config_file); + Ok(Self { opt, config_file,