diff options
| author | salmonik <salmonik@tuta.io> | 2026-07-12 22:09:01 +0200 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-07-12 22:09:01 +0200 |
| commit | 97920e457fdc210049f8d617c053cd40ccaf5cd3 (patch) | |
| tree | d18f649cfe73e1a429911b2870fadde848e26bab | |
| parent | remove unused code, also, third stable (diff) | |
| download | minecraft-ui-97920e457fdc210049f8d617c053cd40ccaf5cd3.tar.gz minecraft-ui-97920e457fdc210049f8d617c053cd40ccaf5cd3.zip | |
create example config on startup
| -rw-r--r-- | src/main.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index 8cbad70..695774a 100644 --- a/src/main.rs +++ b/src/main.rs | |||
| @@ -19,9 +19,15 @@ async fn main() { | |||
| 19 | .with_env_filter(EnvFilter::try_from_default_env().unwrap_or_else(|_| "info".into())) | 19 | .with_env_filter(EnvFilter::try_from_default_env().unwrap_or_else(|_| "info".into())) |
| 20 | .init(); | 20 | .init(); |
| 21 | 21 | ||
| 22 | if !std::path::Path::new("config.toml").exists() { | ||
| 23 | let default = include_str!("../config.toml"); | ||
| 24 | std::fs::write("config.toml", default).expect("Failed to create config.toml"); | ||
| 25 | eprintln!("Created config.toml with default values. Please edit it and restart."); | ||
| 26 | std::process::exit(0); | ||
| 27 | } | ||
| 28 | |||
| 22 | let config = config::Config::load().unwrap_or_else(|e| { | 29 | let config = config::Config::load().unwrap_or_else(|e| { |
| 23 | eprintln!("Configuration error: {e}"); | 30 | eprintln!("Configuration error: {e}"); |
| 24 | eprintln!("Please create a config.toml file based on the example."); | ||
| 25 | std::process::exit(1); | 31 | std::process::exit(1); |
| 26 | }); | 32 | }); |
| 27 | 33 | ||
