diff options
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 +} |