mirror of
https://codeberg.org/insects/cargo-spiel
synced 2025-05-23 02:33:41 +00:00
35 lines
745 B
Rust
35 lines
745 B
Rust
use std::path::PathBuf;
|
|
|
|
use clap::Parser;
|
|
use tokio::runtime::Builder;
|
|
|
|
mod server;
|
|
|
|
#[derive(Parser, Debug)]
|
|
#[command(version)]
|
|
struct CliArgs {
|
|
/// Directory of the Cargo project
|
|
#[arg(short, long)]
|
|
pub project: Option<PathBuf>,
|
|
}
|
|
|
|
fn main() {
|
|
let args = CliArgs::parse();
|
|
let runtime = Builder::new_current_thread()
|
|
.worker_threads(2)
|
|
.enable_io()
|
|
.build()
|
|
.unwrap();
|
|
|
|
let project_path = if let Some(custom_path) = args.project {
|
|
custom_path
|
|
} else {
|
|
std::env::current_dir().unwrap()
|
|
};
|
|
println!(
|
|
"{:>12} Starting server in {}...",
|
|
"spiel",
|
|
project_path.to_str().unwrap()
|
|
);
|
|
runtime.block_on(server::start(project_path));
|
|
}
|