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
#[cfg(not(target_arch = "wasm32"))]
pub mod cli;
#[cfg(not(target_arch = "wasm32"))]
pub mod commands;
#[cfg(not(target_arch = "wasm32"))]
mod error;
#[cfg(not(target_arch = "wasm32"))]
pub(crate) mod helpers;

#[cfg(not(target_arch = "wasm32"))]
pub use error::Error;
#[cfg(not(target_arch = "wasm32"))]
pub type Result<T> = std::result::Result<T, error::Error>;

pub use helpers::{messages::*, USER};

use serde::{Deserialize, Serialize};

/// Command tree used to print help output for the website.
#[doc(hidden)]
#[derive(Debug, Serialize, Deserialize)]
pub struct CommandTree {
    /// Name of the command.
    pub name: String,
    /// Subcommands.
    pub commands: Vec<CommandTree>,
}

impl From<&clap::Command> for CommandTree {
    fn from(value: &clap::Command) -> Self {
        CommandTree {
            name: value.get_name().to_string(),
            commands: value.get_subcommands().map(|c| c.into()).collect(),
        }
    }
}