1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
use clap::{Args, Parser, Subcommand, ValueEnum};
use uuid::Uuid;
#[derive(Parser)]
#[command(
name = "remind",
version,
about = "Create and manage Silicon reminders through Silicon IAM.",
long_about = "Silicon Remind schedules one-time or recurring reminders using five-field Linux cron. Silicons manage their own reminders; Carbons and Silicons can read their organization's reminders.\n\nStart with: remind auth login --org <org>\nThen configure delivery: remind webhook set <url>\nCreate a reminder: remind create --text 'Check the build' --cron '*/5 * * * *'\nUse any command in a saved sandbox: remind --test <test_id> <command>.",
subcommand_required = true,
arg_required_else_help = true
)]
pub struct Cli {
/// Override the server origin for this invocation (credentials stay scoped to that origin).
#[arg(long, global = true, env = "REMIND_URL")]
pub url: Option<String>,
/// Select the organization for this invocation.
#[arg(long, global = true, env = "REMIND_ORG")]
pub org: Option<String>,
/// Run the same command in a saved test environment, using its isolated session.
#[arg(long, global = true)]
pub test: Option<Uuid>,
/// Print machine-readable JSON; suggestions go to stderr only in human mode.
#[arg(long, global = true)]
pub json: bool,
/// Skip this invocation's automatic registry check.
#[arg(long, global = true)]
pub no_update: bool,
/// Reuse a mutation key when retrying the exact same create, edit or status operation.
#[arg(long, global = true)]
pub idempotency_key: Option<String>,
#[command(subcommand)]
pub command: Command,
}
#[derive(Subcommand)]
pub enum Command {
/// Log in using an IAM short-lived token; inspect or revoke the current session.
Auth {
#[command(subcommand)]
command: Auth,
},
/// Create a reminder owned by the signed-in Silicon.
#[command(
after_help = "Examples:\n remind create --text 'Daily standup' --cron '0 9 * * MON-FRI' --timezone Asia/Kolkata\n remind create --text 'One reminder' --cron '30 16 * * *' --kind one-time\n\nConfigure a webhook first with remind webhook set <url>."
)]
Create {
#[arg(long)]
text: String,
#[arg(long)]
cron: String,
#[arg(long, default_value = "UTC")]
timezone: String,
#[arg(long, value_enum, default_value = "recurring")]
kind: Kind,
},
/// List current reminders; use --archived for the 45-day archive.
List {
#[arg(long)]
silicon: Option<String>,
#[arg(long)]
archived: bool,
#[arg(long, value_enum)]
status: Option<Status>,
#[command(flatten)]
page: Page,
},
/// Show one reminder, including its next trigger and archive deadline.
Get { id: Uuid },
/// Change reminder text, cron, timezone or kind. Archived reminders are immutable.
Edit {
id: Uuid,
#[arg(long)]
text: Option<String>,
#[arg(long)]
cron: Option<String>,
#[arg(long)]
timezone: Option<String>,
#[arg(long, value_enum)]
kind: Option<Kind>,
},
/// Atomically pause one or up to 100 owned reminders without archiving them.
Pause {
#[arg(required=true,num_args=1..=100)]
ids: Vec<Uuid>,
},
/// Atomically resume owned reminders and calculate their next future occurrences.
Resume {
#[arg(required=true,num_args=1..=100)]
ids: Vec<Uuid>,
},
/// Archive one owned reminder. It remains readable for 45 days.
Archive { id: Uuid },
/// Inspect delivery attempts, failures and Hook ingress receipt IDs.
Executions {
id: Uuid,
#[command(flatten)]
page: Page,
},
/// List registered Silicons in the current organization.
Silicons {
#[arg(long)]
after: Option<Uuid>,
#[arg(long,default_value_t=50,value_parser=clap::value_parser!(u32).range(1..=100))]
limit: u32,
},
/// Configure, inspect or disable the signed-in Silicon's delivery endpoint.
Webhook {
#[command(subcommand)]
command: Webhook,
},
/// Manage organization-owned test environments using the production session.
Env {
#[command(subcommand)]
command: Environment,
},
/// Inspect the selected sandbox; requires --test <id>.
TestInfo,
/// Configure this sandbox's test-only IAM Application secret (requires --test).
ConfigureIam {
#[arg(long)]
iam_app_secret_file: Option<std::path::PathBuf>,
},
/// Erase all data in the selected sandbox while retaining its key and IAM binding.
#[command(
after_help = "Requires --test <id>. This erases reminders, delivery history, webhook configuration and sandbox logs. It does not clean the linked IAM environment."
)]
Clean,
/// Show or set local server and updater preferences.
Config {
#[command(subcommand)]
command: Config,
},
/// Check crates.io or explicitly update this CLI after the command completes.
Update {
#[arg(long)]
check: bool,
},
/// Probe API liveness or database readiness.
Health {
#[arg(long)]
ready: bool,
},
}
#[derive(Subcommand)]
pub enum Auth {
/// Exchange an IAM SLT; prompt securely, or read it from standard input.
Login {
#[arg(long)]
slt_stdin: bool,
},
/// Show current live IAM identity and organization permissions.
Whoami,
/// Explicitly rotate the current refresh token.
Refresh,
/// Revoke the IAM session, then remove the saved credentials.
Logout,
}
#[derive(Subcommand)]
pub enum Webhook {
/// Register the URL and signing secret issued by Silicon Hook.
Set {
#[arg(value_name = "URL")]
endpoint_url: String,
#[arg(long)]
secret_stdin: bool,
},
/// Show the configured endpoint; the signing secret is never returned.
Get,
/// Disable delivery configuration until it is set again.
Disable,
}
#[derive(Subcommand)]
pub enum Environment {
/// Create an empty Remind environment bound to an existing IAM test environment.
Create {
name: String,
#[arg(long)]
description: Option<String>,
#[arg(long)]
iam_key_file: Option<std::path::PathBuf>,
#[arg(long)]
iam_app_secret_file: Option<std::path::PathBuf>,
},
/// List active environments, optionally including recoverable deleted ones.
List {
#[arg(long)]
include_deleted: bool,
#[arg(long)]
after: Option<Uuid>,
#[arg(long,default_value_t=50,value_parser=clap::value_parser!(u32).range(1..=100))]
limit: u32,
},
/// Inspect one environment's metadata and retention deadlines.
Get { id: Uuid },
/// Retrieve and print an environment key; also save it locally.
Key { id: Uuid },
/// Rotate an environment key and save the successor locally.
Rotate { id: Uuid },
/// Retire an environment; recover it within 30 days using env restore.
Delete { id: Uuid },
/// Restore a retired environment with a fresh root key.
Restore { id: Uuid },
/// Save a shared root key locally; no production session is needed.
Import {
id: Uuid,
#[arg(long)]
key_stdin: bool,
},
/// Forget a saved key and session on this computer; leaves the server untouched.
Forget { id: Uuid },
}
#[derive(Subcommand)]
pub enum Config {
Show,
SetUrl {
#[arg(value_name = "URL")]
service_url: String,
},
AutoUpdate {
#[arg(value_enum)]
value: Toggle,
},
}
#[derive(Clone, Copy, ValueEnum)]
pub enum Toggle {
On,
Off,
}
#[derive(Clone, Copy, ValueEnum)]
pub enum Kind {
OneTime,
Recurring,
}
#[derive(Clone, Copy, ValueEnum)]
pub enum Status {
Active,
Paused,
Completed,
}
#[derive(Args)]
pub struct Page {
#[arg(long)]
cursor: Option<String>,
#[arg(long,default_value_t=50,value_parser=clap::value_parser!(u32).range(1..=100))]
limit: u32,
}
impl Page {
pub fn cursor(&self) -> Option<String> {
self.cursor.clone()
}
pub fn limit(&self) -> u32 {
self.limit
}
}
impl From<Kind> for silicon_remind_client::models::ScheduleKind {
fn from(v: Kind) -> Self {
match v {
Kind::OneTime => Self::OneTime,
Kind::Recurring => Self::Recurring,
}
}
}
impl From<Status> for silicon_remind_client::models::ScheduleStatus {
fn from(v: Status) -> Self {
match v {
Status::Active => Self::Active,
Status::Paused => Self::Paused,
Status::Completed => Self::Completed,
}
}
}