From 6392bf2826ea20d140d8904f7b228e80f5c0cd82 Mon Sep 17 00:00:00 2001 From: raychu86 Date: Wed, 2 Sep 2020 22:28:04 -0700 Subject: [PATCH] Add set_update_automatic to config --- leo/config.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/leo/config.rs b/leo/config.rs index d8bb701ddb..c9ab98df5c 100644 --- a/leo/config.rs +++ b/leo/config.rs @@ -110,6 +110,22 @@ impl 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> {