committed by
Roey Darwish Dror
parent
43f0b75397
commit
0e07d804cc
@@ -38,8 +38,5 @@
|
|||||||
#[commands]
|
#[commands]
|
||||||
#"Python Environment" = "~/dev/.env/bin/pip install -i https://pypi.python.org/simple -U --upgrade-strategy eager jupyter"
|
#"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 temporary or old files
|
||||||
#cleanup = true
|
#cleanup = true
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use directories::BaseDirs;
|
|||||||
use failure::ResultExt;
|
use failure::ResultExt;
|
||||||
use strum::{EnumIter, EnumString, EnumVariantNames, IntoEnumIterator};
|
use strum::{EnumIter, EnumString, EnumVariantNames, IntoEnumIterator};
|
||||||
|
|
||||||
use log::{debug, error, LevelFilter};
|
use log::{debug, LevelFilter};
|
||||||
use pretty_env_logger::formatted_timed_builder;
|
use pretty_env_logger::formatted_timed_builder;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use shellexpand;
|
use shellexpand;
|
||||||
@@ -64,7 +64,6 @@ pub struct ConfigFile {
|
|||||||
yay_arguments: Option<String>,
|
yay_arguments: Option<String>,
|
||||||
no_retry: Option<bool>,
|
no_retry: Option<bool>,
|
||||||
run_in_tmux: Option<bool>,
|
run_in_tmux: Option<bool>,
|
||||||
verbose: Option<bool>,
|
|
||||||
cleanup: Option<bool>,
|
cleanup: Option<bool>,
|
||||||
only: Option<Vec<Step>>,
|
only: Option<Vec<Step>>,
|
||||||
}
|
}
|
||||||
@@ -75,8 +74,8 @@ impl ConfigFile {
|
|||||||
if !config_path.exists() {
|
if !config_path.exists() {
|
||||||
write(&config_path, include_str!("../config.example.toml"))
|
write(&config_path, include_str!("../config.example.toml"))
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
error!(
|
debug!(
|
||||||
"Unable to write the example configuration file to {}: {}",
|
"Unable to write the example configuration file to {}: {}. Using blank config.",
|
||||||
config_path.display(),
|
config_path.display(),
|
||||||
e
|
e
|
||||||
);
|
);
|
||||||
@@ -184,18 +183,19 @@ impl Config {
|
|||||||
/// The function parses the command line arguments and reading the configuration file.
|
/// The function parses the command line arguments and reading the configuration file.
|
||||||
pub fn load(base_dirs: &BaseDirs) -> Result<Self, Error> {
|
pub fn load(base_dirs: &BaseDirs) -> Result<Self, Error> {
|
||||||
let opt = CommandLineArgs::from_args();
|
let opt = CommandLineArgs::from_args();
|
||||||
let config_file = ConfigFile::read(base_dirs)?;
|
|
||||||
|
|
||||||
let mut builder = formatted_timed_builder();
|
let mut builder = formatted_timed_builder();
|
||||||
|
|
||||||
if opt.verbose || config_file.verbose.unwrap_or(false) {
|
if opt.verbose {
|
||||||
builder.filter(Some("topgrade"), LevelFilter::Trace);
|
builder.filter(Some("topgrade"), LevelFilter::Trace);
|
||||||
}
|
}
|
||||||
|
|
||||||
let allowed_steps = Self::allowed_steps(&opt, &config_file);
|
|
||||||
|
|
||||||
builder.init();
|
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 {
|
Ok(Self {
|
||||||
opt,
|
opt,
|
||||||
config_file,
|
config_file,
|
||||||
|
|||||||
Reference in New Issue
Block a user