aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs37
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);
+ }
+ }
+}