Skip to main content

agent_first_mail/cli/
contacts.rs

1use clap::{Args, Subcommand};
2
3#[derive(Subcommand, Debug)]
4pub enum ContactCommand {
5    /// Create a new contact record.
6    Create(ContactCreateArgs),
7    /// List contacts, optionally filtered by group, tag, org, or role.
8    List {
9        /// Filter to a specific group.
10        #[arg(long)]
11        group: Option<String>,
12        /// Filter by tag.
13        #[arg(long)]
14        tag: Option<String>,
15        /// Filter by organization.
16        #[arg(long)]
17        org: Option<String>,
18        /// Filter by role.
19        #[arg(long)]
20        role: Option<String>,
21    },
22    /// Show a contact's full file content.
23    Show {
24        /// Contact ref: pYYYYMMDDNNN or pYYYYMMDDNNN-any-suffix.
25        contact_ref: String,
26    },
27    /// Move a contact to a different group.
28    Move {
29        /// Contact ref: pYYYYMMDDNNN or pYYYYMMDDNNN-any-suffix.
30        contact_ref: String,
31        /// Destination group.
32        #[arg(long)]
33        group: String,
34    },
35    /// Rename a contact's display name.
36    Rename {
37        /// Contact ref: pYYYYMMDDNNN or pYYYYMMDDNNN-any-suffix.
38        contact_ref: String,
39        /// New display name.
40        #[arg(long)]
41        name: String,
42    },
43    /// Add or remove email addresses for a contact.
44    Email {
45        #[command(subcommand)]
46        action: ContactEmailAction,
47    },
48    /// Add or remove phone numbers for a contact.
49    Phone {
50        #[command(subcommand)]
51        action: ContactPhoneAction,
52    },
53    /// Add a tag to a contact.
54    Tag {
55        /// Contact ref: pYYYYMMDDNNN or pYYYYMMDDNNN-any-suffix.
56        contact_ref: String,
57        /// Tag to add.
58        tag: String,
59    },
60    /// Remove a tag from a contact.
61    Untag {
62        /// Contact ref: pYYYYMMDDNNN or pYYYYMMDDNNN-any-suffix.
63        contact_ref: String,
64        /// Tag to remove.
65        tag: String,
66    },
67    /// Show or edit contact notes.
68    Notes {
69        #[command(subcommand)]
70        action: ContactNotesAction,
71    },
72    /// Archive an active contact.
73    Archive {
74        /// Contact ref: pYYYYMMDDNNN or pYYYYMMDDNNN-any-suffix.
75        contact_ref: String,
76        /// Why this contact is being archived; required by default.
77        #[arg(long)]
78        reason: Option<String>,
79    },
80    /// Reopen an archived contact as active.
81    Reopen {
82        /// Contact ref: pYYYYMMDDNNN or pYYYYMMDDNNN-any-suffix.
83        contact_ref: String,
84        /// Destination group. Defaults to contact.default_group in config.
85        #[arg(long)]
86        group: Option<String>,
87        /// Why this contact should be reopened; required by default.
88        #[arg(long)]
89        reason: Option<String>,
90    },
91    /// Extract stub contacts from message senders not yet in the contact list.
92    Extract {
93        /// Extract from triage messages only.
94        #[arg(long, conflicts_with_all = ["from_case", "all"])]
95        from_triage: bool,
96        /// Extract from a specific case's messages.
97        #[arg(long = "from-case", value_name = "CASE_REF", conflicts_with_all = ["from_triage", "all"])]
98        from_case: Option<String>,
99        /// Extract from all triage and case messages.
100        #[arg(long, conflicts_with_all = ["from_triage", "from_case"])]
101        all: bool,
102        /// Destination group for created contacts. Defaults to contact.default_group.
103        #[arg(long)]
104        group: Option<String>,
105    },
106}
107
108#[derive(Args, Debug, Clone)]
109pub struct ContactCreateArgs {
110    /// Display name for the contact.
111    #[arg(long)]
112    pub name: String,
113    /// Group. Defaults to the configured default contact group.
114    #[arg(long)]
115    pub group: Option<String>,
116    /// Email address. Repeatable.
117    #[arg(long = "email")]
118    pub emails: Vec<String>,
119    /// Phone number. Repeatable.
120    #[arg(long = "phone")]
121    pub phones: Vec<String>,
122    /// Organization name.
123    #[arg(long)]
124    pub org: Option<String>,
125    /// Role or title.
126    #[arg(long)]
127    pub role: Option<String>,
128    /// Tag. Repeatable.
129    #[arg(long = "tag")]
130    pub tags: Vec<String>,
131}
132
133#[derive(Subcommand, Debug)]
134pub enum ContactEmailAction {
135    /// Add an email address to the contact.
136    Add {
137        /// Contact ref: pYYYYMMDDNNN or pYYYYMMDDNNN-any-suffix.
138        contact_ref: String,
139        /// Email address to add.
140        email: String,
141    },
142    /// Remove an email address from the contact.
143    Remove {
144        /// Contact ref: pYYYYMMDDNNN or pYYYYMMDDNNN-any-suffix.
145        contact_ref: String,
146        /// Email address to remove.
147        email: String,
148    },
149}
150
151#[derive(Subcommand, Debug)]
152pub enum ContactPhoneAction {
153    /// Add a phone number to the contact.
154    Add {
155        /// Contact ref: pYYYYMMDDNNN or pYYYYMMDDNNN-any-suffix.
156        contact_ref: String,
157        /// Phone number to add.
158        phone: String,
159    },
160    /// Remove a phone number from the contact.
161    Remove {
162        /// Contact ref: pYYYYMMDDNNN or pYYYYMMDDNNN-any-suffix.
163        contact_ref: String,
164        /// Phone number to remove.
165        phone: String,
166    },
167}
168
169#[derive(Subcommand, Debug)]
170pub enum ContactNotesAction {
171    /// Show notes markdown.
172    Show {
173        /// Contact ref: pYYYYMMDDNNN or pYYYYMMDDNNN-any-suffix.
174        contact_ref: String,
175    },
176    /// Append text to notes markdown.
177    Append {
178        /// Contact ref: pYYYYMMDDNNN or pYYYYMMDDNNN-any-suffix.
179        contact_ref: String,
180        /// Markdown text to append.
181        #[arg(long)]
182        text: String,
183    },
184    /// Replace notes markdown with text.
185    Replace {
186        /// Contact ref: pYYYYMMDDNNN or pYYYYMMDDNNN-any-suffix.
187        contact_ref: String,
188        /// Markdown text to write.
189        #[arg(long)]
190        text: String,
191    },
192}