aboutsummaryrefslogtreecommitdiff
path: root/src/help.rs
blob: 188f4758ab04d20f12a9fb0a5e8c4c2f9a471d1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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
}