All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 10s
31 lines
810 B
Rust
31 lines
810 B
Rust
use std::net::SocketAddr;
|
|
|
|
use clap::{Parser, command};
|
|
use nuchat::run;
|
|
use tracing::{Level, event};
|
|
|
|
#[derive(Parser, Debug)]
|
|
#[command(version, about, long_about = None)]
|
|
struct Args {
|
|
/// Host to bind to
|
|
#[arg(long, default_value = "127.0.0.1")]
|
|
host: String,
|
|
|
|
/// Port to use
|
|
#[arg(long, default_value_t = 7000)]
|
|
port: u16,
|
|
}
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<(), std::io::Error> {
|
|
let args = Args::parse();
|
|
let str_address = format!("{}:{}", args.host, args.port);
|
|
let address: SocketAddr = str_address
|
|
.parse()
|
|
.unwrap_or_else(|_| panic!("could not parse address: {str_address}"));
|
|
let listener = tokio::net::TcpListener::bind(address).await?;
|
|
let result = run(listener)?.await;
|
|
event!(Level::INFO, "Server stopped");
|
|
result
|
|
}
|