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/help.rs | |
download | blom-86098797034cbc7eb6db0cee54e17f8dcaedbc5d.tar.gz |
Diffstat (limited to 'src/help.rs')
-rw-r--r-- | src/help.rs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/help.rs b/src/help.rs new file mode 100644 index 0000000..188f475 --- /dev/null +++ b/src/help.rs @@ -0,0 +1,43 @@ +use std::process::ExitCode; + +use crate::query; +use crate::repl; +use crate::server; + +pub const USAGE: &str = " +Usage: blom [command] [options] + +Commands: + + server Start the blom server. + + repl Start the blom repl. + query <query> Send <query> to the blom server. + + help [<command>] Print usage. + +General options: + + -h, --help Print usage. +"; + +pub fn cmd(args: &[String]) -> ExitCode { + if args.is_empty() { + println!("{}", USAGE); + return ExitCode::from(0); + } + + match args[0].as_str() { + "server" => println!("{}", server::USAGE), + "repl" => println!("{}", repl::USAGE), + "query" => println!("{}", query::USAGE), + "help" => println!("{}", USAGE), + _ => { + println!("{}", USAGE); + eprintln!("Unknown command {}.", args[0]); + return ExitCode::from(1); + } + } + + ExitCode::SUCCESS +} |