From 86098797034cbc7eb6db0cee54e17f8dcaedbc5d Mon Sep 17 00:00:00 2001 From: evuez Date: Sat, 26 Nov 2022 15:38:06 -0500 Subject: Initial commit --- src/main.rs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/main.rs (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..f39c5fc --- /dev/null +++ b/src/main.rs @@ -0,0 +1,37 @@ +#![feature(addr_parse_ascii)] + +use std::env; +use std::process::ExitCode; + +mod common; +mod help; +mod query; +mod repl; +mod server; + +fn main() -> ExitCode { + env_logger::init(); + + let args: Vec = env::args().collect(); + + if args.len() <= 1 { + println!("{}", help::USAGE); + eprintln!("Expected command argument."); + return ExitCode::from(1); + } + + let cmd = &args[1]; + let cmd_args = &args[2..]; + + match cmd.as_str() { + "server" => return server::cmd(cmd_args), + "repl" => return repl::cmd(cmd_args), + "query" => return query::cmd(cmd_args), + "help" | "-h" | "--help" => return help::cmd(cmd_args), + _ => { + println!("{}", help::USAGE); + eprintln!("Unknown command {}.", cmd); + return ExitCode::from(1); + } + } +} -- cgit v1.2.3