From 86098797034cbc7eb6db0cee54e17f8dcaedbc5d Mon Sep 17 00:00:00 2001 From: evuez Date: Sat, 26 Nov 2022 15:38:06 -0500 Subject: Initial commit --- src/help.rs | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/help.rs (limited to 'src/help.rs') 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 Send to the blom server. + + help [] 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 +} -- cgit v1.2.3