diff options
author | evuez <julien@mulga.net> | 2022-11-26 15:38:06 -0500 |
---|---|---|
committer | evuez <julien@mulga.net> | 2024-04-03 22:44:12 +0200 |
commit | 86098797034cbc7eb6db0cee54e17f8dcaedbc5d (patch) | |
tree | 29b6225ead843eb9022296a54657bbadfa1c4da0 /src/main.rs | |
download | blom-86098797034cbc7eb6db0cee54e17f8dcaedbc5d.tar.gz |
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 37 |
1 files changed, 37 insertions, 0 deletions
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<String> = 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); + } + } +} |