committed by
Roey Darwish Dror
parent
43f0b75397
commit
0e07d804cc
@@ -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
|
||||
|
||||
@@ -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<String>,
|
||||
no_retry: Option<bool>,
|
||||
run_in_tmux: Option<bool>,
|
||||
verbose: Option<bool>,
|
||||
cleanup: Option<bool>,
|
||||
only: Option<Vec<Step>>,
|
||||
}
|
||||
@@ -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<Self, Error> {
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user