summaryrefslogtreecommitdiffstats
path: root/src/cli.rs
blob: 1eae2466f1a66655f3d05c23d18ac32e5dafdec5 (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
use std::path::PathBuf;

use structopt::StructOpt;
use anyhow::Error;

#[derive(Debug, StructOpt)]
#[structopt(name = "distrox", about = "Distrox - The distributed social network")]
pub struct CLI {
    #[structopt(short, long)]
    debug: bool,

    #[structopt(short, long)]
    trace: bool,

    #[structopt(parse(from_os_str))]
    configfile: Option<PathBuf>,

    #[structopt(subcommand)]
    cmd: Option<Command>
}

impl CLI {
    pub fn cmd(&self) -> Option<&Command> {
        self.cmd.as_ref()
    }
}

#[derive(Debug, PartialEq, StructOpt)]
#[structopt(about = "Start the server part (running in foreground")]
pub enum Command {
    Server,
}

pub fn cli() -> Result<CLI, Error> {
    Ok(CLI::from_args())
}