snarkos_cli/commands/
mod.rs1mod account;
17pub use account::*;
18
19mod clean;
20pub use clean::*;
21
22mod developer;
23pub use developer::*;
24
25mod start;
26pub use start::*;
27
28mod update;
29pub use update::*;
30
31use anstyle::{AnsiColor, Color, Style};
32use anyhow::Result;
33use clap::{Parser, builder::Styles};
34
35const HEADER_COLOR: Option<Color> = Some(Color::Ansi(AnsiColor::Yellow));
36const LITERAL_COLOR: Option<Color> = Some(Color::Ansi(AnsiColor::Green));
37const STYLES: Styles = Styles::plain()
38 .header(Style::new().bold().fg_color(HEADER_COLOR))
39 .usage(Style::new().bold().fg_color(HEADER_COLOR))
40 .literal(Style::new().bold().fg_color(LITERAL_COLOR));
41
42#[derive(Debug, Parser)]
44#[clap(name = "snarkOS", author = "The Aleo Team <hello@aleo.org>", styles = STYLES, version)]
45pub struct CLI {
46 #[clap(default_value = "2", short, long)]
48 pub verbosity: u8,
49 #[clap(subcommand)]
51 pub command: Command,
52}
53
54#[derive(Debug, Parser)]
55pub enum Command {
56 #[clap(subcommand)]
57 Account(Account),
58 #[clap(name = "clean")]
59 Clean(Clean),
60 #[clap(subcommand)]
61 Developer(Developer),
62 #[clap(name = "start")]
63 Start(Box<Start>),
64 #[clap(name = "update")]
65 Update(Update),
66}
67
68impl Command {
69 pub fn parse(self) -> Result<String> {
71 match self {
72 Self::Account(command) => command.parse(),
73 Self::Clean(command) => command.parse(),
74 Self::Developer(command) => command.parse(),
75 Self::Start(command) => command.parse(),
76 Self::Update(command) => command.parse(),
77 }
78 }
79}
80
81#[cfg(test)]
82mod tests {
83 use super::*;
84
85 #[test]
87 fn verify_cli() {
88 use clap::CommandFactory;
89 CLI::command().debug_assert()
90 }
91}