feat(rust): add configuration parsing and an error type

This commit is contained in:
Reed Krantz
2026-02-18 19:37:30 -06:00
parent 4365e9f739
commit 2f6157b062
4 changed files with 72 additions and 5 deletions

View File

@@ -1,4 +1,8 @@
use clap::Parser;
use figment::{
Figment,
providers::{Env, Format, Json, Toml},
};
use tracing::{Level, event};
mod args;
@@ -6,10 +10,19 @@ use args::{ActionType, CommandArgs};
mod config;
mod error;
use error::CommandError;
#[tokio::main]
async fn main() {
async fn main() -> Result<(), CommandError> {
let args = CommandArgs::parse();
let config: config::CommandConfig = Figment::new()
.admerge(Json::file("config.json"))
.admerge(Toml::file("config.toml"))
.admerge(Env::prefixed("APP_"))
.extract()?;
match &args.action {
ActionType::Serve(serve_args) => {
tracing_subscriber::fmt()
@@ -24,7 +37,11 @@ async fn main() {
println!("{:#?}", args);
// println!("{:#?}", config);
println!("{:#?}", config);
println!("{:#?}", config.port.ports);
}
}
Ok(())
}