Skip to content

Commit 56c9cbe

Browse files
committed
feat: add clap and print version
1 parent 4d7c01c commit 56c9cbe

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

Cargo.lock

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ edition = "2021"
66
[dependencies]
77
env_logger = "0.11.6"
88
log = "0.4.25"
9+
clap = { version = "4.5", features = ["derive", "env"] }
910

1011
serde = { version = "1.0", features = ["derive"] }
1112
serde_json = "1.0"

src/main.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::sync::Arc;
22

33
use axum::{routing::any, Router};
4+
use clap::Parser;
45
use config::Config;
56

67
use crate::{config::ASRConfig, services::realtime_ws::StableRealtimeConfig};
@@ -11,11 +12,22 @@ pub mod protocol;
1112
pub mod services;
1213
pub mod util;
1314

15+
#[derive(Parser, Debug)]
16+
#[command(version)]
17+
struct Args {
18+
#[clap(
19+
default_value = "config.toml",
20+
help = "Path to config file",
21+
env = "CONFIG_PATH"
22+
)]
23+
config: String,
24+
}
25+
1426
#[tokio::main]
1527
async fn main() {
1628
env_logger::init();
17-
let config_path = std::env::args().nth(1).unwrap_or("config.toml".to_string());
18-
let config = config::Config::load(&config_path).unwrap();
29+
let args = Args::parse();
30+
let config = config::Config::load(&args.config).unwrap();
1931

2032
let listener = tokio::net::TcpListener::bind(&config.addr).await.unwrap();
2133
let mut mcp_clients = vec![];

0 commit comments

Comments
 (0)