Skip to main content

auths_cli/
cli.rs

1use std::path::PathBuf;
2
3use clap::builder::styling::{AnsiColor, Effects, Styles};
4use clap::{Parser, Subcommand};
5
6use crate::commands::account::AccountCommand;
7use crate::commands::agent::AgentCommand;
8use crate::commands::approval::ApprovalCommand;
9use crate::commands::artifact::ArtifactCommand;
10use crate::commands::audit::AuditCommand;
11use crate::commands::auth::AuthCommand;
12
13use crate::commands::commit::CommitCmd;
14use crate::commands::completions::CompletionsCommand;
15use crate::commands::compliance::ComplianceCommand;
16use crate::commands::config::ConfigCommand;
17use crate::commands::credential::CredentialCommand;
18use crate::commands::debug::DebugCmd;
19use crate::commands::demo::DemoCommand;
20use crate::commands::device::DeviceCommand;
21use crate::commands::device::pair::PairCommand;
22use crate::commands::did_webs::DidWebsCommand;
23use crate::commands::doctor::DoctorCommand;
24use crate::commands::emergency::EmergencyCommand;
25use crate::commands::error_lookup::ErrorLookupCommand;
26use crate::commands::id::IdCommand;
27use crate::commands::init::InitCommand;
28use crate::commands::ipex::IpexCommand;
29use crate::commands::kel::KelCommand;
30use crate::commands::keri_emit::KeriEmitCommand;
31use crate::commands::key::KeyCommand;
32use crate::commands::key_state::KeyStateCommand;
33use crate::commands::learn::LearnCommand;
34use crate::commands::log::LogCommand;
35use crate::commands::multi_sig::MultiSigCommand;
36use crate::commands::namespace::NamespaceCommand;
37use crate::commands::oobi::OobiCommand;
38use crate::commands::org::OrgCommand;
39use crate::commands::policy::PolicyCommand;
40use crate::commands::publish::PublishCommand;
41use crate::commands::reset::ResetCommand;
42use crate::commands::scim::ScimCommand;
43use crate::commands::sign::SignCommand;
44use crate::commands::status::StatusCommand;
45use crate::commands::tls_cert::TlsCertCommand;
46use crate::commands::treasury::TreasuryCommand;
47use crate::commands::trust::TrustCommand;
48use crate::commands::unified_verify::UnifiedVerifyCommand;
49use crate::commands::whoami::WhoamiCommand;
50use crate::commands::witness::WitnessCommand;
51
52fn cli_styles() -> Styles {
53    Styles::styled()
54        .header(AnsiColor::Blue.on_default() | Effects::BOLD)
55        .usage(AnsiColor::Blue.on_default() | Effects::BOLD)
56        .literal(AnsiColor::Cyan.on_default() | Effects::BOLD)
57        .placeholder(AnsiColor::Cyan.on_default())
58        .error(AnsiColor::Red.on_default() | Effects::BOLD)
59        .valid(AnsiColor::Green.on_default() | Effects::BOLD)
60        .invalid(AnsiColor::Yellow.on_default() | Effects::BOLD)
61}
62
63#[derive(Parser, Debug)]
64#[command(
65    name = "auths",
66    about = "\x1b[1;32mauths \u{2014} cryptographic identity for developers and agents\x1b[0m",
67    version,
68    styles = cli_styles(),
69    after_help = "Run 'auths <command> --help' for details on any command.\nRun 'auths --help-all' for all commands including advanced ones."
70)]
71pub struct AuthsCli {
72    #[command(subcommand)]
73    pub command: Option<RootCommand>,
74
75    #[clap(long, help = "Show all commands including advanced ones")]
76    pub help_all: bool,
77
78    #[clap(short = 'j', long, global = true, help = "Emit machine-readable JSON")]
79    pub json: bool,
80
81    #[clap(short, long, global = true, help = "Suppress non-essential output")]
82    pub quiet: bool,
83
84    #[clap(
85        long,
86        value_parser,
87        global = true,
88        help = "Override the local storage directory (default: ~/.auths)"
89    )]
90    pub repo: Option<PathBuf>,
91}
92
93#[derive(Subcommand, Debug)]
94#[command(rename_all = "lowercase")]
95pub enum RootCommand {
96    // ── Primary ──
97    Init(InitCommand),
98    Sign(SignCommand),
99    Verify(UnifiedVerifyCommand),
100    Status(StatusCommand),
101    Whoami(WhoamiCommand),
102
103    // ── Setup & Troubleshooting ──
104    Demo(DemoCommand),
105    Pair(PairCommand),
106    Trust(TrustCommand),
107    Doctor(DoctorCommand),
108    Tutorial(LearnCommand),
109
110    // ── Utilities ──
111    Config(ConfigCommand),
112    Completions(CompletionsCommand),
113
114    // ── Advanced (visible via --help-all) ──
115    #[command(hide = true)]
116    Publish(PublishCommand),
117    #[command(hide = true)]
118    Artifact(ArtifactCommand),
119    #[command(hide = true)]
120    Reset(ResetCommand),
121    #[command(hide = true)]
122    Error(ErrorLookupCommand),
123    #[command(hide = true)]
124    Id(IdCommand),
125    #[command(hide = true)]
126    Device(DeviceCommand),
127    #[command(hide = true)]
128    Key(KeyCommand),
129    Kel(KelCommand),
130    #[command(hide = true, name = "key-state")]
131    KeyState(KeyStateCommand),
132    #[command(hide = true, name = "did-webs")]
133    DidWebs(DidWebsCommand),
134    #[command(hide = true, name = "keri-emit")]
135    KeriEmit(KeriEmitCommand),
136    #[command(hide = true, name = "tls-cert")]
137    TlsCert(TlsCertCommand),
138    #[command(hide = true)]
139    Oobi(OobiCommand),
140    #[command(hide = true)]
141    Ipex(IpexCommand),
142    #[command(hide = true)]
143    Approval(ApprovalCommand),
144    #[command(hide = true)]
145    Policy(PolicyCommand),
146    #[command(hide = true)]
147    Namespace(NamespaceCommand),
148    #[command(hide = true)]
149    Org(OrgCommand),
150    #[command(hide = true)]
151    Compliance(ComplianceCommand),
152    #[command(hide = true)]
153    Credential(CredentialCommand),
154    #[command(hide = true)]
155    Audit(AuditCommand),
156    #[command(hide = true)]
157    Auth(AuthCommand),
158
159    // ── Internal (visible via --help-all) ──
160    #[command(hide = true)]
161    Emergency(EmergencyCommand),
162    #[command(hide = true)]
163    Agent(AgentCommand),
164    /// Aggregate treasury cap across a manager's sub-delegated agents.
165    Treasury(TreasuryCommand),
166    #[command(hide = true)]
167    Witness(WitnessCommand),
168    #[command(hide = true)]
169    Scim(ScimCommand),
170    #[command(hide = true)]
171    Commit(CommitCmd),
172    #[command(hide = true)]
173    Debug(DebugCmd),
174    #[command(hide = true)]
175    Log(LogCommand),
176    #[command(hide = true)]
177    Account(AccountCommand),
178    #[command(hide = true, name = "multi-sig")]
179    MultiSig(MultiSigCommand),
180}