From 82e9361e1aa823409c466c069bc76709a07b67d2 Mon Sep 17 00:00:00 2001 From: Lucas Schwiderski Date: Wed, 5 Apr 2023 11:13:41 +0200 Subject: [PATCH] fix(dtmm): Fix creating default config Fixes #98. --- crates/dtmm/src/main.rs | 29 +---------------------------- crates/dtmm/src/util/config.rs | 2 +- 2 files changed, 2 insertions(+), 29 deletions(-) diff --git a/crates/dtmm/src/main.rs b/crates/dtmm/src/main.rs index 288f1f1..d02dc5b 100644 --- a/crates/dtmm/src/main.rs +++ b/crates/dtmm/src/main.rs @@ -52,38 +52,11 @@ fn main() -> Result<()> { let (action_tx, action_rx) = tokio::sync::mpsc::unbounded_channel(); - // let config = util::config::read_config(&default_config_path, &matches) - // .wrap_err("Failed to read config file")?; - // let game_info = dtmt_shared::collect_game_info(); - - // tracing::debug!(?config, ?game_info); - - // let game_dir = config.game_dir.or_else(|| game_info.map(|i| i.path)); - // if game_dir.is_none() { - // let err = - // eyre::eyre!("No Game Directory set. Head to the 'Settings' tab to set it manually",); - // event_sink - // .submit_command(ACTION_SHOW_ERROR_DIALOG, SingleUse::new(err), Target::Auto) - // .expect("failed to send command"); - // } - - // let initial_state = { - // let mut state = State::new( - // config.path, - // game_dir.unwrap_or_default(), - // config.data_dir.unwrap_or_default(), - // config.nexus_api_key.unwrap_or_default(), - // ); - // state.mods = load_mods(state.get_mod_dir(), config.mod_order.iter()) - // .wrap_err("Failed to load mods")?; - // state - // }; - let config_path = matches .get_one::("config") .cloned() .expect("argument has default value"); - let is_config_default = matches.value_source("config") != Some(ValueSource::DefaultValue); + let is_config_default = matches.value_source("config") == Some(ValueSource::DefaultValue); if action_tx .send(AsyncAction::LoadInitial((config_path, is_config_default))) .is_err() diff --git a/crates/dtmm/src/util/config.rs b/crates/dtmm/src/util/config.rs index e0fde55..1cafeae 100644 --- a/crates/dtmm/src/util/config.rs +++ b/crates/dtmm/src/util/config.rs @@ -151,7 +151,7 @@ where .wrap_err("Failed to serialize default config value")?; fs::write(&config.path, data).await.wrap_err_with(|| { format!( - "failed to write default config to {}", + "Failed to write default config to {}", config.path.display() ) })?; -- 2.45.3