summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorJoe Carstairs <me@joeac.net>2026-09-04 18:50:53 +0100
committerJoe Carstairs <me@joeac.net>2026-09-04 18:50:53 +0100
commit5270c5c73fc9e843b922f1e12b81c3c78d7e8a26 (patch)
tree864ee1f5fd962e87a2ca7690b22974fc24068a3d /src/main.rs
parentd6426030b3572545a58234a780b94e746135f13b (diff)
config file from arg or default location
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 705b33b..b445285 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,11 +1,24 @@
+mod config;
+
use clap::Parser;
+use crate::config::Config;
+
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct Args {
+ /// Path to the config file. If blank, searches default config locations.
+ #[arg(short = 'c', long = "config", default_value = "")]
+ config_file: String,
}
fn main() {
- let _args = Args::parse();
- println!("Hello, world!");
+ let args = Args::parse();
+ let _config = match args.config_file.as_str() {
+ "" => Config::find_config().unwrap_or_else(||
+ panic!("Failed to find config. Paths searched: {:#?}", config::DEFAULT_CONFIG_FILE_LOCATIONS)),
+ path => Config::parse_config_file_at_path(&path).unwrap_or_else(|err|
+ panic!("Failed to parse config at {}. Error: {}", path, err)),
+ };
+ println!("Found config file.");
}