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::agent::AgentCommand;
7use crate::commands::approval::ApprovalCommand;
8use crate::commands::artifact::ArtifactCommand;
9use crate::commands::audit::AuditCommand;
10use crate::commands::commit::CommitCmd;
11use crate::commands::completions::CompletionsCommand;
12use crate::commands::config::ConfigCommand;
13use crate::commands::debug::DebugCmd;
14use crate::commands::device::DeviceCommand;
15use crate::commands::device::pair::PairCommand;
16use crate::commands::doctor::DoctorCommand;
17use crate::commands::emergency::EmergencyCommand;
18use crate::commands::git::GitCommand;
19use crate::commands::id::IdCommand;
20use crate::commands::init::InitCommand;
21use crate::commands::key::KeyCommand;
22use crate::commands::learn::LearnCommand;
23use crate::commands::org::OrgCommand;
24use crate::commands::policy::PolicyCommand;
25use crate::commands::scim::ScimCommand;
26use crate::commands::sign::SignCommand;
27use crate::commands::status::StatusCommand;
28use crate::commands::trust::TrustCommand;
29use crate::commands::unified_verify::UnifiedVerifyCommand;
30use crate::commands::whoami::WhoamiCommand;
31use crate::commands::witness::WitnessCommand;
32use crate::config::OutputFormat;
33
34fn cli_styles() -> Styles {
35    Styles::styled()
36        .header(AnsiColor::Blue.on_default() | Effects::BOLD)
37        .usage(AnsiColor::Blue.on_default() | Effects::BOLD)
38        .literal(AnsiColor::Cyan.on_default() | Effects::BOLD)
39        .placeholder(AnsiColor::Cyan.on_default())
40        .error(AnsiColor::Red.on_default() | Effects::BOLD)
41        .valid(AnsiColor::Green.on_default() | Effects::BOLD)
42        .invalid(AnsiColor::Yellow.on_default() | Effects::BOLD)
43}
44
45#[derive(Parser, Debug)]
46#[command(
47    name = "auths",
48    about = "\x1b[1;32mauths \u{2014} cryptographic identity for developers and agents\x1b[0m",
49    version,
50    styles = cli_styles(),
51    after_help = "Run 'auths <command> --help' for details on any command.\nRun 'auths --help-all' for advanced commands (id, device, key, policy, ...)."
52)]
53pub struct AuthsCli {
54    #[command(subcommand)]
55    pub command: Option<RootCommand>,
56
57    #[clap(long, help = "Show all commands including advanced ones")]
58    pub help_all: bool,
59
60    #[clap(
61        long,
62        value_enum,
63        default_value = "text",
64        global = true,
65        hide = true,
66        help = "Output format (text or json)"
67    )]
68    pub format: OutputFormat,
69
70    #[clap(long, global = true, help = "Emit machine-readable JSON")]
71    pub json: bool,
72
73    #[clap(short, long, global = true, help = "Suppress non-essential output")]
74    pub quiet: bool,
75
76    #[clap(
77        long,
78        value_parser,
79        global = true,
80        help = "Override the local storage directory (default: ~/.auths)"
81    )]
82    pub repo: Option<PathBuf>,
83}
84
85#[derive(Subcommand, Debug)]
86#[command(rename_all = "lowercase")]
87pub enum RootCommand {
88    Init(InitCommand),
89    Sign(SignCommand),
90    Verify(UnifiedVerifyCommand),
91    Status(StatusCommand),
92    Whoami(WhoamiCommand),
93    Tutorial(LearnCommand),
94    Doctor(DoctorCommand),
95    Pair(PairCommand),
96    #[command(hide = true)]
97    Completions(CompletionsCommand),
98    #[command(hide = true)]
99    Emergency(EmergencyCommand),
100
101    #[command(hide = true)]
102    Id(IdCommand),
103    #[command(hide = true)]
104    Device(DeviceCommand),
105    #[command(hide = true)]
106    Key(KeyCommand),
107    #[command(hide = true)]
108    Approval(ApprovalCommand),
109    #[command(hide = true)]
110    Artifact(ArtifactCommand),
111    #[command(hide = true)]
112    Policy(PolicyCommand),
113    #[command(hide = true)]
114    Git(GitCommand),
115    #[command(hide = true)]
116    Trust(TrustCommand),
117    #[command(hide = true)]
118    Org(OrgCommand),
119    #[command(hide = true)]
120    Audit(AuditCommand),
121    #[command(hide = true)]
122    Agent(AgentCommand),
123    #[command(hide = true)]
124    Witness(WitnessCommand),
125    #[command(hide = true)]
126    Scim(ScimCommand),
127    #[command(hide = true)]
128    Config(ConfigCommand),
129
130    #[command(hide = true)]
131    Commit(CommitCmd),
132    #[command(hide = true)]
133    Debug(DebugCmd),
134}