summaryrefslogtreecommitdiffstats
path: root/tedge/src/cli.rs
blob: 63730cccc920b1d520ddd83c9647d94315f41945 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use std::path::PathBuf;

#[derive(Debug, clap::Parser)]
#[clap(
    name = clap::crate_name!(),
    version = clap::crate_version!(),
    about = clap::crate_description!()
)]
pub struct Cli {
    /// Enable logging
    ///
    /// If not specified, only WARN and ERROR messages will be logged.
    /// If set to "off" or "false", no logging will be done at all.
    ///
    /// This setting overwrites the logging specification set via the RUST_LOG env variable.
    #[clap(short, long, arg_enum)]
    pub logging: Option<LoggingSpec>,

    /// Enable chrome compatible tracing output
    ///
    /// If set, chrome-compatible tracing output will be written to the file specified.
    #[clap(long)]
    pub chrome_logging: Option<PathBuf>,

    /// Enable tracy compatible tracing output
    ///
    /// If set, "tracy" compatible tracing output will be produced
    #[clap(long)]
    pub tracy_logging: bool,

    #[clap(subcommand)]
    pub command: CliCommand,
}

#[derive(Copy, Clone, Debug, clap::ArgEnum)]
pub enum LoggingSpec {
    False,
    Off,
    Trace,
    Debug,
    Info,
    Warn,
    Error,
}

#[derive(Debug, clap::Subcommand)]
pub enum CliCommand {
    /// Run thin-edge with the passed configuration
    #[clap(name = "run")]
    Run { config: PathBuf },

    /// Validate the passed configuration
    #[clap(name = "validate-config")]
    ValidateConfig { config: PathBuf },

    /// Print the supported plugin kinds
    #[clap(name = "get-plugin-kinds")]
    GetPluginKinds,

    /// Print the documentation of the configuration of the available plugins
    #[clap(name = "doc")]
    Doc {
        /// Print the doc only for this plugin
        plugin_name: Option<String>,
    },

    #[clap(name = "bugreport")]
    BugReport,
}