sos_cli_helpers/lib.rs
1//! Helper types and functions for the [Save Our Secrets](https://saveoursecrets.com) command line [executables](https://saveoursecrets.com/command-line-tools/).
2
3pub mod messages;
4
5/// Command tree used to print help output for the website.
6#[derive(Debug, serde::Serialize, serde::Deserialize)]
7pub struct CommandTree {
8 /// Name of the command.
9 pub name: String,
10 /// Subcommands.
11 pub commands: Vec<CommandTree>,
12}
13
14impl From<&clap::Command> for CommandTree {
15 fn from(value: &clap::Command) -> Self {
16 CommandTree {
17 name: value.get_name().to_string(),
18 commands: value.get_subcommands().map(|c| c.into()).collect(),
19 }
20 }
21}