extern crate core;
use std::process::exit;
use clap::{Parser, Subcommand};
use env_logger::Env;
use crate::repl::{repl_main, ReplArgs};
use crate::server::{server_main, ServerArgs};
mod client;
mod repl;
mod server;
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
#[command(propagate_version = true)]
struct AppArgs {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
Server(ServerArgs),
Repl(ReplArgs),
}
fn main() {
match AppArgs::parse().command {
Commands::Server(args) => {
env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
.unwrap()
.block_on(server_main(args))
}
Commands::Repl(args) => {
if let Err(e) = repl_main(args) {
eprintln!("{e}");
exit(-1);
}
}
};
}