Add clap cmdline args to unshell-server

This commit is contained in:
Michael Mikovsky
2025-12-01 09:54:12 -07:00
parent b321528fcd
commit 97bd45571b
6 changed files with 158 additions and 2 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ pub async fn start_api(address: &str) {
pub async fn protected(
Path(path): Path<String>,
Extension(_currentUser): Extension<CurrentUser>,
Extension(_): Extension<CurrentUser>,
) -> impl IntoResponse {
info!("{}", path);
// Json(UserResponse {
+5
View File
@@ -0,0 +1,5 @@
// Calc 3 ends Tuesday next week
pub struct Database {
// db:
}
+1
View File
@@ -1,4 +1,5 @@
// #![macro_use]
mod api;
mod database;
pub use api::app::start_api;
+23 -1
View File
@@ -1,8 +1,30 @@
use unshell_server::start_api;
use clap::Parser;
use static_init::dynamic;
#[dynamic]
static DEFAULT_HOST: String = "localhost".to_string();
/// A fictional versioning CLI
#[derive(Debug, Parser)]
#[command(name = "unshell-server")]
#[command(about = "UnShell server", long_about = None)]
pub struct Args {
/// Host to listen on
#[clap(long, default_value_t = DEFAULT_HOST.clone())]
host: String,
/// Port to listen
#[arg(short, long, default_value_t = 3000)]
port: usize,
}
#[tokio::main]
async fn main() {
let args = Args::parse();
unshell_lib::logger::PrettyLogger::init();
start_api("localhost:3000").await;
start_api(&format!("{}:{}", args.host, args.port)).await;
}