mirror of
https://github.com/Astatin3/unshell.git
synced 2026-06-09 06:47:59 -06:00
Add clap cmdline args to unshell-server
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// Calc 3 ends Tuesday next week
|
||||
|
||||
pub struct Database {
|
||||
// db:
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
// #![macro_use]
|
||||
|
||||
mod api;
|
||||
mod database;
|
||||
pub use api::app::start_api;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user