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::doctor::DoctorCommand;
23use crate::commands::emergency::EmergencyCommand;
24use crate::commands::error_lookup::ErrorLookupCommand;
25use crate::commands::id::IdCommand;
26use crate::commands::init::InitCommand;
27use crate::commands::key::KeyCommand;
28use crate::commands::learn::LearnCommand;
29use crate::commands::log::LogCommand;
30use crate::commands::multi_sig::MultiSigCommand;
31use crate::commands::namespace::NamespaceCommand;
32use crate::commands::org::OrgCommand;
33use crate::commands::policy::PolicyCommand;
34use crate::commands::publish::PublishCommand;
35use crate::commands::reset::ResetCommand;
36use crate::commands::scim::ScimCommand;
37use crate::commands::sign::SignCommand;
38use crate::commands::sign_commit::SignCommitCommand;
39use crate::commands::status::StatusCommand;
40use crate::commands::trust::TrustCommand;
41use crate::commands::unified_verify::UnifiedVerifyCommand;
42use crate::commands::whoami::WhoamiCommand;
43use crate::commands::witness::WitnessCommand;
44
45fn cli_styles() -> Styles {
46    Styles::styled()
47        .header(AnsiColor::Blue.on_default() | Effects::BOLD)
48        .usage(AnsiColor::Blue.on_default() | Effects::BOLD)
49        .literal(AnsiColor::Cyan.on_default() | Effects::BOLD)
50        .placeholder(AnsiColor::Cyan.on_default())
51        .error(AnsiColor::Red.on_default() | Effects::BOLD)
52        .valid(AnsiColor::Green.on_default() | Effects::BOLD)
53        .invalid(AnsiColor::Yellow.on_default() | Effects::BOLD)
54}
55
56#[derive(Parser, Debug)]
57#[command(
58    name = "auths",
59    about = "\x1b[1;32mauths \u{2014} cryptographic identity for developers and agents\x1b[0m",
60    version,
61    styles = cli_styles(),
62    after_help = "Run 'auths <command> --help' for details on any command.\nRun 'auths --help-all' for all commands including advanced ones."
63)]
64pub struct AuthsCli {
65    #[command(subcommand)]
66    pub command: Option<RootCommand>,
67
68    #[clap(long, help = "Show all commands including advanced ones")]
69    pub help_all: bool,
70
71    #[clap(short = 'j', long, global = true, help = "Emit machine-readable JSON")]
72    pub json: bool,
73
74    #[clap(short, long, global = true, help = "Suppress non-essential output")]
75    pub quiet: bool,
76
77    #[clap(
78        long,
79        value_parser,
80        global = true,
81        help = "Override the local storage directory (default: ~/.auths)"
82    )]
83    pub repo: Option<PathBuf>,
84}
85
86#[derive(Subcommand, Debug)]
87#[command(rename_all = "lowercase")]
88pub enum RootCommand {
89    // ── Primary ──
90    Init(InitCommand),
91    Sign(SignCommand),
92    Verify(UnifiedVerifyCommand),
93    Status(StatusCommand),
94    Whoami(WhoamiCommand),
95
96    // ── Setup & Troubleshooting ──
97    Demo(DemoCommand),
98    Pair(PairCommand),
99    Trust(TrustCommand),
100    Doctor(DoctorCommand),
101    Tutorial(LearnCommand),
102
103    // ── Utilities ──
104    Config(ConfigCommand),
105    Completions(CompletionsCommand),
106
107    // ── Advanced (visible via --help-all) ──
108    #[command(hide = true)]
109    Publish(PublishCommand),
110    #[command(hide = true)]
111    Artifact(ArtifactCommand),
112    #[command(hide = true)]
113    Reset(ResetCommand),
114    #[command(hide = true)]
115    SignCommit(SignCommitCommand),
116    #[command(hide = true)]
117    Error(ErrorLookupCommand),
118    #[command(hide = true)]
119    Id(IdCommand),
120    #[command(hide = true)]
121    Device(DeviceCommand),
122    #[command(hide = true)]
123    Key(KeyCommand),
124    #[command(hide = true)]
125    Approval(ApprovalCommand),
126    #[command(hide = true)]
127    Policy(PolicyCommand),
128    #[command(hide = true)]
129    Namespace(NamespaceCommand),
130    #[command(hide = true)]
131    Org(OrgCommand),
132    #[command(hide = true)]
133    Compliance(ComplianceCommand),
134    #[command(hide = true)]
135    Credential(CredentialCommand),
136    #[command(hide = true)]
137    Audit(AuditCommand),
138    #[command(hide = true)]
139    Auth(AuthCommand),
140
141    // ── Internal (visible via --help-all) ──
142    #[command(hide = true)]
143    Emergency(EmergencyCommand),
144    #[command(hide = true)]
145    Agent(AgentCommand),
146    #[command(hide = true)]
147    Witness(WitnessCommand),
148    #[command(hide = true)]
149    Scim(ScimCommand),
150    #[command(hide = true)]
151    Commit(CommitCmd),
152    #[command(hide = true)]
153    Debug(DebugCmd),
154    #[command(hide = true)]
155    Log(LogCommand),
156    #[command(hide = true)]
157    Account(AccountCommand),
158    #[command(hide = true, name = "multi-sig")]
159    MultiSig(MultiSigCommand),
160}