Fix editing broken configuration (fix #241)

This commit is contained in:
Roey Darwish Dror
2019-11-04 22:55:06 +02:00
parent 4e1e0788f8
commit 1182675170
2 changed files with 14 additions and 12 deletions

View File

@@ -166,6 +166,12 @@ pub struct CommandLineArgs {
yes: bool,
}
impl CommandLineArgs {
pub fn edit_config(&self) -> bool {
self.edit_config
}
}
/// Represents the application configuration
///
/// The struct holds the loaded configuration file, as well as the arguments parsed from the command line.
@@ -181,9 +187,7 @@ impl Config {
/// Load the configuration.
///
/// 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();
pub fn load(base_dirs: &BaseDirs, opt: CommandLineArgs) -> Result<Self, Error> {
let mut builder = formatted_timed_builder();
if opt.verbose {
@@ -292,11 +296,6 @@ impl Config {
self.opt.keep_at_end || env::var("TOPGRADE_KEEP_END").is_ok()
}
/// Whether to edit the configuration file
pub fn edit_config(&self) -> bool {
self.opt.edit_config
}
/// Whether to set the terminal title
pub fn set_title(&self) -> bool {
self.config_file.set_title.unwrap_or(true)