feat(rust): add initial rust template

This commit is contained in:
Reed Krantz
2026-01-12 15:31:13 -06:00
parent 14fb214dad
commit 6c51c7cba0
9 changed files with 817 additions and 0 deletions

26
rust/src/args.rs Normal file
View File

@@ -0,0 +1,26 @@
use clap::{Args, Parser, Subcommand};
use tracing::Level;
#[derive(Debug, Parser)]
#[clap(version, about)]
pub struct CommandArgs {
/// The path to the TOML configuration. This will override all other configuration sources
#[arg(short, long)]
pub config: Option<String>,
#[clap(subcommand)]
pub action: ActionType,
}
#[derive(Debug, Subcommand)]
pub enum ActionType {
/// Run the daemon and listen for requests
Serve(ServeAction),
}
#[derive(Debug, Args)]
pub struct ServeAction {
/// The log level to use for the server
#[arg(short, long, default_value_t = Level::WARN)]
pub log_level: Level,
}

4
rust/src/config.rs Normal file
View File

@@ -0,0 +1,4 @@
use serde::Deserialize;
#[derive(Deserialize)]
struct CommandConfig {}

32
rust/src/main.rs Normal file
View File

@@ -0,0 +1,32 @@
use clap::Parser;
use tracing::{Level, event};
mod args;
use args::CommandArgs;
mod config;
use crate::args::ActionType;
#[tokio::main]
async fn main() {
let args = CommandArgs::parse();
match &args.action {
ActionType::Serve(serve_args) => {
tracing_subscriber::fmt()
.with_max_level(serve_args.log_level)
.init();
event!(Level::ERROR, "error");
event!(Level::WARN, "warn");
event!(Level::INFO, "info");
event!(Level::DEBUG, "debug");
event!(Level::TRACE, "trace");
println!("{:#?}", args);
// println!("{:#?}", config);
}
}
}