diff options
author | Clement Tsang <34804052+ClementTsang@users.noreply.github.com> | 2020-09-22 18:12:36 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-22 18:12:36 -0400 |
commit | 6db76029e2419d53c81cb2111e487f83ee248a2f (patch) | |
tree | 356ff9a92b2d6024d581a6466f832080f2adccbd /src/bin | |
parent | b0b174eb9843e9af55f5c3f2d37cae96f1744a6b (diff) |
feature: Beginnings of in-app config (#231)
Initial refactorings and additions to support in-app config.
- Refactor our current options logic to support in-app configs. That is, we can write to a config file with our changes now.
- The default action when creating a new config file is to leave it blank. (TBD and for now, not sure on this one)
- Previously, we would set everything in a config file on startup; now we need to read from the config TOML struct whenever.
- `C` keybind is now occupied for configs.
- `no_write` option to never write to a config file.
Diffstat (limited to 'src/bin')
-rw-r--r-- | src/bin/main.rs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/bin/main.rs b/src/bin/main.rs index 83b740f9..37056e78 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -32,7 +32,7 @@ fn main() -> Result<()> { } let matches = clap::get_matches(); - let config_path = read_config(matches.value_of("CONFIG_LOCATION")) + let config_path = read_config(matches.value_of("config_location")) .context("Unable to access the given config file location.")?; let config: Config = create_or_get_config(&config_path) .context("Unable to properly parse or create the config file.")?; @@ -49,6 +49,7 @@ fn main() -> Result<()> { &widget_layout, default_widget_id, &default_widget_type_option, + config_path, )?; // Create painter and set colours. @@ -56,10 +57,8 @@ fn main() -> Result<()> { widget_layout, app.app_config_fields.table_gap, app.app_config_fields.use_basic_mode, - ); - generate_config_colours(&config, &mut painter)?; - painter.colours.generate_remaining_cpu_colours(); - painter.complete_painter_init(); + &config, + )?; // Set up input handling let (sender, receiver) = mpsc::channel(); @@ -80,7 +79,7 @@ fn main() -> Result<()> { // Event loop let (reset_sender, reset_receiver) = mpsc::channel(); - create_event_thread( + create_collection_thread( sender, reset_receiver, &app.app_config_fields, @@ -105,8 +104,7 @@ fn main() -> Result<()> { ctrlc::set_handler(move || { ist_clone.store(true, Ordering::SeqCst); termination_hook(); - }) - .unwrap(); + })?; let mut first_run = true; while !is_terminated.load(Ordering::SeqCst) { |