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