pigeon/commands/keyring/cli.rs
1use clap::{Args, Subcommand};
2
3use crate::commands::keyring::email::provider::Provider;
4
5#[derive(Args, Debug)]
6pub struct KeyringArgs {
7 #[command(subcommand)]
8 pub command: KeyringCommands,
9}
10
11#[derive(Subcommand, Debug)]
12pub enum KeyringCommands {
13 /// Add a new email identity, bucket-config, or encryption key
14 Add(AddArgs),
15 /// Edit an existing entry's fields
16 Modify {
17 /// Alias of the entry to edit. Interactively selected from every
18 /// configured entry (of any kind) when omitted.
19 alias: Option<String>,
20 },
21 /// Remove a configured entry and its secret
22 Delete {
23 /// Alias of the entry to remove.
24 alias: String,
25 },
26 /// List every configured entry
27 List,
28}
29
30#[derive(Args, Debug)]
31pub struct AddArgs {
32 #[command(subcommand)]
33 pub kind: Option<AddKind>,
34}
35
36#[derive(Subcommand, Debug)]
37pub enum AddKind {
38 /// Authenticate an email identity and register it under a local alias
39 Email {
40 /// Email address of the identity to authenticate, e.g. first.last@example.com
41 email: String,
42
43 /// Local alias to store this identity under (e.g. first-last).
44 /// Defaults to a sanitized form of the email's local part.
45 #[arg(long)]
46 alias: Option<String>,
47
48 /// Email provider. Auto-detected from the email's domain when
49 /// omitted, falling back to an interactive prompt if detection fails.
50 #[arg(long)]
51 provider: Option<Provider>,
52
53 /// IMAP host, e.g. imap.example.com. Required when --provider is
54 /// "custom" (or resolves to it); ignored for known providers, which
55 /// use their own well-known host.
56 #[arg(long)]
57 host: Option<String>,
58
59 /// IMAP port. Defaults to 993 for a custom provider when omitted;
60 /// ignored for known providers, which use their own well-known port.
61 #[arg(long)]
62 port: Option<u16>,
63 },
64
65 /// Interactively configure a new S3-compatible bucket-config
66 Bucket {
67 /// Alias to register this bucket-config under (e.g. "backup").
68 /// Prompted if omitted.
69 alias: Option<String>,
70 },
71
72 /// Register a new symmetric encryption key, generated or imported
73 /// (ADR-0026)
74 EncryptionKey {
75 /// Alias to register this key under (e.g. "primary"). Prompted if
76 /// omitted.
77 alias: Option<String>,
78 },
79}