Add set_update_automatic to config

This commit is contained in:
raychu86 2020-09-02 22:28:04 -07:00
parent 3d3f4e8588
commit 6392bf2826

View File

@ -110,6 +110,22 @@ impl Config {
Ok(config) Ok(config)
} }
/// Update the `automatic` configuration in the `config.toml` file.
pub fn set_update_automatic(automatic: bool) -> Result<(), CLIError> {
let mut config = Self::read_config()?;
if config.update.automatic != automatic {
config.update.automatic = automatic;
// Update the config file
let config_path = LEO_CONFIG_PATH.clone();
let default_config_string = toml::to_string(&Config::default())?;
fs::write(&config_path, default_config_string)?;
}
Ok(())
}
} }
pub fn write_token(token: &str) -> Result<(), io::Error> { pub fn write_token(token: &str) -> Result<(), io::Error> {