| fce44ae9 Andy McCall ↶ |
1 |
|
| 2 |
|
| 3 |
mod format; |
| 75167672 Andy McCall |
4 |
mod identity; |
| c6aa5bd9 Andy McCall ↶ |
5 |
mod json; |
| d82e4409 Andy McCall ↶ |
6 |
mod proposal; |
| fce44ae9 Andy McCall ↶ |
7 |
mod sync; |
| 135212de Andy McCall ↶ |
8 |
pub mod ui; |
| fce44ae9 Andy McCall ↶ |
9 |
mod workspace; |
| 10 |
|
| 11 |
use anyhow::{Context, Result}; |
| 12 |
use clap::{Parser, Subcommand}; |
| 13 |
use oxy_core::repo::Repo; |
| 14 |
use std::path::PathBuf; |
| 15 |
|
| 16 |
#[derive(Parser)] |
| 75167672 Andy McCall |
17 |
#[command( |
| 18 |
name = "oxy", |
| 19 |
version, |
| 20 |
about = "Oxygen: breathing fresh air into version control" |
| 21 |
)] |
| fce44ae9 Andy McCall ↶ |
22 |
struct Cli { |
| 135212de Andy McCall ↶ |
23 |
|
| 24 |
#[arg(long, global = true)] |
| 25 |
plain: bool, |
| fce44ae9 Andy McCall ↶ |
26 |
#[command(subcommand)] |
| 27 |
cmd: Cmd, |
| 28 |
} |
| 29 |
|
| 30 |
#[derive(Subcommand)] |
| 31 |
enum Cmd { |
| 32 |
|
| e02bf0cd Andy McCall ↶ |
33 |
Init { |
| d42369ab Andy McCall |
34 |
|
| e02bf0cd Andy McCall ↶ |
35 |
path: Option<PathBuf>, |
| 36 |
|
| 37 |
#[arg(long)] |
| 38 |
bare: bool, |
| 39 |
}, |
| fce44ae9 Andy McCall ↶ |
40 |
|
| b3c5a59a Andy McCall ↶ |
41 |
Clone { |
| d42369ab Andy McCall |
42 |
|
| b3c5a59a Andy McCall ↶ |
43 |
url: String, |
| d42369ab Andy McCall |
44 |
|
| b3c5a59a Andy McCall ↶ |
45 |
dest: Option<PathBuf>, |
| 46 |
|
| 47 |
#[arg(long)] |
| 48 |
max_blob: Option<String>, |
| 7421309f Andy McCall ↶ |
49 |
|
| 50 |
#[arg(long = "sparse")] |
| 51 |
sparse: Vec<String>, |
| 2863456a Andy McCall ↶ |
52 |
|
| 53 |
#[arg(long)] |
| 54 |
depth: Option<u32>, |
| b3c5a59a Andy McCall ↶ |
55 |
}, |
| 2863456a Andy McCall ↶ |
56 |
|
| 57 |
Deepen { |
| d42369ab Andy McCall |
58 |
|
| 2863456a Andy McCall ↶ |
59 |
#[arg(default_value_t = 10)] |
| 60 |
depth: u32, |
| d42369ab Andy McCall |
61 |
|
| 2863456a Andy McCall ↶ |
62 |
#[arg(long, default_value = "origin")] |
| 63 |
remote: String, |
| 64 |
}, |
| 7421309f Andy McCall ↶ |
65 |
|
| d42369ab Andy McCall |
66 |
Sparse { |
| 67 |
|
| 68 |
paths: Vec<String>, |
| 69 |
}, |
| fce44ae9 Andy McCall ↶ |
70 |
|
| 50a046e4 Andy McCall ↶ |
71 |
Status { |
| 72 |
|
| 73 |
#[arg(long)] |
| 74 |
json: bool, |
| 75 |
}, |
| 135212de Andy McCall ↶ |
76 |
|
| 77 |
Prompt { |
| 694805cc Andy McCall ↶ |
78 |
|
| 135212de Andy McCall ↶ |
79 |
#[arg(long, default_value = oxy_core::repo::DEFAULT_PROMPT_FORMAT)] |
| 80 |
format: String, |
| 694805cc Andy McCall ↶ |
81 |
|
| 82 |
#[arg(long)] |
| 83 |
glyphs: bool, |
| 84 |
|
| 85 |
#[arg(long, value_parser = ["raw", "bash", "zsh"])] |
| 86 |
color: Option<String>, |
| 135212de Andy McCall ↶ |
87 |
}, |
| fce44ae9 Andy McCall ↶ |
88 |
|
| 89 |
Commit { |
| d42369ab Andy McCall |
90 |
|
| fce44ae9 Andy McCall ↶ |
91 |
#[arg(short, long)] |
| 92 |
message: String, |
| 93 |
|
| 94 |
#[arg(long = "depends-on")] |
| 95 |
depends_on: Vec<String>, |
| 957fee30 Andy McCall ↶ |
96 |
|
| 97 |
paths: Vec<String>, |
| 98 |
|
| 99 |
#[arg(short, long)] |
| 100 |
interactive: bool, |
| c6aa5bd9 Andy McCall ↶ |
101 |
|
| 102 |
#[arg(long, value_delimiter = ',')] |
| 103 |
hunks: Vec<usize>, |
| fce44ae9 Andy McCall ↶ |
104 |
}, |
| 728da0f9 Andy McCall ↶ |
105 |
|
| 106 |
Squash { |
| d42369ab Andy McCall |
107 |
|
| 728da0f9 Andy McCall ↶ |
108 |
change: String, |
| d42369ab Andy McCall |
109 |
|
| 728da0f9 Andy McCall ↶ |
110 |
#[arg(long)] |
| 111 |
into: String, |
| 112 |
}, |
| 113 |
|
| 114 |
Rebase { |
| d42369ab Andy McCall |
115 |
|
| 728da0f9 Andy McCall ↶ |
116 |
change: String, |
| 117 |
|
| 118 |
#[arg(long, required = true, num_args = 1..)] |
| 119 |
onto: Vec<String>, |
| 120 |
}, |
| 957fee30 Andy McCall ↶ |
121 |
|
| 122 |
Blame { |
| d42369ab Andy McCall |
123 |
|
| 957fee30 Andy McCall ↶ |
124 |
path: String, |
| d42369ab Andy McCall |
125 |
|
| 957fee30 Andy McCall ↶ |
126 |
#[arg(long)] |
| 127 |
json: bool, |
| 128 |
}, |
| 129 |
|
| 130 |
Bisect { |
| 131 |
#[command(subcommand)] |
| 132 |
cmd: BisectCmd, |
| 133 |
}, |
| fce44ae9 Andy McCall ↶ |
134 |
|
| 94084087 Andy McCall ↶ |
135 |
Log { |
| 136 |
|
| 137 |
#[arg(short = 'n', long)] |
| 138 |
limit: Option<usize>, |
| 139 |
|
| 140 |
#[arg(short, long)] |
| 141 |
verbose: bool, |
| c6aa5bd9 Andy McCall ↶ |
142 |
|
| 143 |
#[arg(long)] |
| 144 |
path: Option<String>, |
| d42369ab Andy McCall |
145 |
|
| c6aa5bd9 Andy McCall ↶ |
146 |
#[arg(long)] |
| 147 |
json: bool, |
| 94084087 Andy McCall ↶ |
148 |
}, |
| fce44ae9 Andy McCall ↶ |
149 |
|
| c6aa5bd9 Andy McCall ↶ |
150 |
Diff { |
| 151 |
|
| 152 |
change: Option<String>, |
| d42369ab Andy McCall |
153 |
|
| c6aa5bd9 Andy McCall ↶ |
154 |
#[arg(long)] |
| 155 |
json: bool, |
| 156 |
}, |
| 157 |
|
| 158 |
Cat { |
| d42369ab Andy McCall |
159 |
|
| c6aa5bd9 Andy McCall ↶ |
160 |
path: String, |
| 161 |
|
| 162 |
#[arg(short = 'r', long)] |
| 163 |
change: Option<String>, |
| 164 |
}, |
| 165 |
|
| 166 |
Root { |
| d42369ab Andy McCall |
167 |
|
| c6aa5bd9 Andy McCall ↶ |
168 |
#[arg(long)] |
| 169 |
json: bool, |
| 170 |
}, |
| 171 |
|
| 172 |
Version { |
| d42369ab Andy McCall |
173 |
|
| c6aa5bd9 Andy McCall ↶ |
174 |
#[arg(long)] |
| 175 |
json: bool, |
| 176 |
}, |
| 177 |
|
| 178 |
Discard { |
| d42369ab Andy McCall |
179 |
|
| c6aa5bd9 Andy McCall ↶ |
180 |
paths: Vec<String>, |
| 181 |
|
| 182 |
#[arg(long, value_delimiter = ',')] |
| 183 |
hunks: Vec<usize>, |
| 184 |
}, |
| 185 |
|
| 186 |
Hunks { |
| d42369ab Andy McCall |
187 |
|
| c6aa5bd9 Andy McCall ↶ |
188 |
#[arg(long)] |
| 189 |
json: bool, |
| 190 |
}, |
| 614541c3 Andy McCall ↶ |
191 |
|
| 192 |
Describe { |
| d42369ab Andy McCall |
193 |
|
| 614541c3 Andy McCall ↶ |
194 |
#[arg(short, long)] |
| 195 |
message: String, |
| d42369ab Andy McCall |
196 |
|
| 614541c3 Andy McCall ↶ |
197 |
change: Option<String>, |
| 198 |
}, |
| 23b217d7 Andy McCall ↶ |
199 |
|
| 614541c3 Andy McCall ↶ |
200 |
Amend { |
| d42369ab Andy McCall |
201 |
|
| 614541c3 Andy McCall ↶ |
202 |
#[arg(short, long)] |
| 203 |
message: Option<String>, |
| 23b217d7 Andy McCall ↶ |
204 |
|
| 205 |
#[arg(long)] |
| 206 |
into: Option<String>, |
| 614541c3 Andy McCall ↶ |
207 |
}, |
| 23b217d7 Andy McCall ↶ |
208 |
|
| d42369ab Andy McCall |
209 |
Split { |
| 210 |
|
| 211 |
change: String, |
| 212 |
|
| 213 |
paths: Vec<String>, |
| 214 |
}, |
| 614541c3 Andy McCall ↶ |
215 |
|
| d42369ab Andy McCall |
216 |
Abandon { |
| 217 |
|
| 218 |
change: String, |
| 219 |
}, |
| fce44ae9 Andy McCall ↶ |
220 |
|
| c6aa5bd9 Andy McCall ↶ |
221 |
Show { |
| d42369ab Andy McCall |
222 |
|
| c6aa5bd9 Andy McCall ↶ |
223 |
change: String, |
| d42369ab Andy McCall |
224 |
|
| c6aa5bd9 Andy McCall ↶ |
225 |
#[arg(long)] |
| 226 |
json: bool, |
| 227 |
}, |
| fce44ae9 Andy McCall ↶ |
228 |
|
| 229 |
Checkout { |
| d42369ab Andy McCall |
230 |
|
| fce44ae9 Andy McCall ↶ |
231 |
changes: Vec<String>, |
| 232 |
|
| 233 |
#[arg(long)] |
| 234 |
discard: bool, |
| 1c2bd9ab Andy McCall ↶ |
235 |
|
| 236 |
|
| 237 |
#[arg(long, conflicts_with = "discard")] |
| 238 |
carry: bool, |
| fce44ae9 Andy McCall ↶ |
239 |
}, |
| 240 |
|
| c6aa5bd9 Andy McCall ↶ |
241 |
Resolve { |
| d42369ab Andy McCall |
242 |
|
| c6aa5bd9 Andy McCall ↶ |
243 |
#[arg(long)] |
| 244 |
json: bool, |
| 245 |
}, |
| fce44ae9 Andy McCall ↶ |
246 |
|
| 247 |
Undo, |
| 252e8cb2 Andy McCall ↶ |
248 |
|
| 249 |
Checkpoint, |
| d42369ab Andy McCall |
250 |
|
| 251 |
Completions { |
| 252 |
|
| 253 |
shell: clap_complete::Shell, |
| 254 |
}, |
| 255 |
|
| 256 |
Man { |
| 257 |
|
| 258 |
#[arg(long)] |
| 259 |
dir: Option<PathBuf>, |
| 260 |
}, |
| 3e5772cc Andy McCall ↶ |
261 |
|
| 262 |
Doctor { |
| 263 |
|
| 264 |
#[arg(long)] |
| 265 |
offline: bool, |
| d42369ab Andy McCall |
266 |
|
| 3e5772cc Andy McCall ↶ |
267 |
#[arg(long)] |
| 268 |
json: bool, |
| 269 |
}, |
| 387335ff Andy McCall ↶ |
270 |
|
| 271 |
Fsck { |
| d42369ab Andy McCall |
272 |
|
| 387335ff Andy McCall ↶ |
273 |
#[arg(long)] |
| 274 |
json: bool, |
| 275 |
}, |
| ba160f60 Andy McCall ↶ |
276 |
|
| 277 |
Gc { |
| 278 |
|
| 279 |
#[arg(long)] |
| 280 |
now: bool, |
| 281 |
}, |
| fce44ae9 Andy McCall ↶ |
282 |
|
| 283 |
#[command(name = "op")] |
| 284 |
Op { |
| 285 |
#[command(subcommand)] |
| 286 |
cmd: OpCmd, |
| 287 |
}, |
| cdb5beba Andy McCall ↶ |
288 |
|
| d42369ab Andy McCall |
289 |
Lock { |
| 290 |
|
| 291 |
path: String, |
| 292 |
}, |
| cdb5beba Andy McCall ↶ |
293 |
|
| d42369ab Andy McCall |
294 |
Unlock { |
| 295 |
|
| 296 |
path: String, |
| 297 |
}, |
| 4e88e774 Andy McCall ↶ |
298 |
|
| 299 |
Workspace { |
| 300 |
#[command(subcommand)] |
| 301 |
cmd: WorkspaceCmd, |
| 302 |
}, |
| 7b9809e6 Andy McCall ↶ |
303 |
|
| 304 |
Bookmark { |
| 305 |
#[command(subcommand)] |
| 306 |
cmd: BookmarkCmd, |
| 307 |
}, |
| 308 |
|
| d42369ab Andy McCall |
309 |
Merge { |
| 310 |
|
| 311 |
bookmark: String, |
| 312 |
}, |
| 4dee277c Andy McCall ↶ |
313 |
|
| 314 |
Submodule { |
| 315 |
#[command(subcommand)] |
| 316 |
cmd: SubmoduleCmd, |
| 317 |
}, |
| 132b884b Andy McCall ↶ |
318 |
|
| 319 |
Tag { |
| 320 |
#[command(subcommand)] |
| 321 |
cmd: TagCmd, |
| 322 |
}, |
| fce44ae9 Andy McCall ↶ |
323 |
|
| 324 |
Remote { |
| 325 |
#[command(subcommand)] |
| 326 |
cmd: RemoteCmd, |
| 327 |
}, |
| 328 |
|
| c6aa5bd9 Andy McCall ↶ |
329 |
Fetch { |
| d42369ab Andy McCall |
330 |
|
| c6aa5bd9 Andy McCall ↶ |
331 |
remote: Option<String>, |
| d42369ab Andy McCall |
332 |
|
| c6aa5bd9 Andy McCall ↶ |
333 |
#[arg(long)] |
| 334 |
json: bool, |
| 335 |
}, |
| fce44ae9 Andy McCall ↶ |
336 |
|
| c6aa5bd9 Andy McCall ↶ |
337 |
Pull { |
| d42369ab Andy McCall |
338 |
|
| c6aa5bd9 Andy McCall ↶ |
339 |
remote: Option<String>, |
| d42369ab Andy McCall |
340 |
|
| c6aa5bd9 Andy McCall ↶ |
341 |
#[arg(long)] |
| 342 |
json: bool, |
| 343 |
}, |
| fce44ae9 Andy McCall ↶ |
344 |
|
| 345 |
Push { |
| d42369ab Andy McCall |
346 |
|
| fce44ae9 Andy McCall ↶ |
347 |
remote: Option<String>, |
| 348 |
|
| 349 |
#[arg(long)] |
| 350 |
force: bool, |
| 7b9809e6 Andy McCall ↶ |
351 |
|
| 352 |
#[arg(short = 'b', long)] |
| 353 |
bookmark: Option<String>, |
| d42369ab Andy McCall |
354 |
|
| c6aa5bd9 Andy McCall ↶ |
355 |
#[arg(long)] |
| 356 |
json: bool, |
| fce44ae9 Andy McCall ↶ |
357 |
}, |
| 2b5ee371 Andy McCall ↶ |
358 |
|
| fce44ae9 Andy McCall ↶ |
359 |
Serve { |
| 360 |
|
| 361 |
#[arg(long, default_value = ".")] |
| 362 |
root: PathBuf, |
| d42369ab Andy McCall |
363 |
|
| fce44ae9 Andy McCall ↶ |
364 |
#[arg(long, default_value = "127.0.0.1:8890")] |
| 365 |
bind: String, |
| 366 |
|
| 367 |
#[arg(long = "token")] |
| 368 |
tokens: Vec<String>, |
| 2b5ee371 Andy McCall ↶ |
369 |
|
| 370 |
#[arg(long, requires = "tls_key")] |
| 371 |
tls_cert: Option<PathBuf>, |
| 372 |
|
| 373 |
#[arg(long, requires = "tls_cert")] |
| 374 |
tls_key: Option<PathBuf>, |
| fce44ae9 Andy McCall ↶ |
375 |
}, |
| 376 |
|
| 377 |
Identity { |
| 378 |
#[command(subcommand)] |
| 379 |
cmd: IdentityCmd, |
| 380 |
}, |
| 05e71ed6 Andy McCall ↶ |
381 |
|
| 382 |
Seal { |
| d42369ab Andy McCall |
383 |
|
| 05e71ed6 Andy McCall ↶ |
384 |
changes: Vec<String>, |
| d82e4409 Andy McCall ↶ |
385 |
|
| 386 |
#[arg(long, conflicts_with = "changes")] |
| 387 |
proposal: Option<String>, |
| d42369ab Andy McCall |
388 |
|
| 05e71ed6 Andy McCall ↶ |
389 |
#[arg(long)] |
| 390 |
json: bool, |
| 391 |
}, |
| d82e4409 Andy McCall ↶ |
392 |
|
| 393 |
Proposal { |
| 394 |
#[command(subcommand)] |
| 395 |
cmd: ProposalCmd, |
| 396 |
}, |
| fce44ae9 Andy McCall ↶ |
397 |
|
| c6aa5bd9 Andy McCall ↶ |
398 |
Verify { |
| d42369ab Andy McCall |
399 |
|
| c6aa5bd9 Andy McCall ↶ |
400 |
change: Option<String>, |
| d42369ab Andy McCall |
401 |
|
| c6aa5bd9 Andy McCall ↶ |
402 |
#[arg(long)] |
| 403 |
json: bool, |
| 404 |
}, |
| 79ab8528 Andy McCall ↶ |
405 |
|
| 406 |
Git { |
| 407 |
#[command(subcommand)] |
| 408 |
cmd: GitCmd, |
| 409 |
}, |
| 83e0677b Andy McCall ↶ |
410 |
|
| 411 |
Policy { |
| 412 |
#[command(subcommand)] |
| 413 |
cmd: PolicyCmd, |
| 414 |
}, |
| 7421309f Andy McCall ↶ |
415 |
|
| fce44ae9 Andy McCall ↶ |
416 |
Config { |
| d42369ab Andy McCall |
417 |
|
| fce44ae9 Andy McCall ↶ |
418 |
key: String, |
| d42369ab Andy McCall |
419 |
|
| fce44ae9 Andy McCall ↶ |
420 |
value: String, |
| 421 |
|
| 422 |
#[arg(long)] |
| 423 |
user: bool, |
| 424 |
}, |
| 425 |
} |
| 426 |
|
| 427 |
#[derive(Subcommand)] |
| 428 |
enum OpCmd { |
| d42369ab Andy McCall |
429 |
|
| c6aa5bd9 Andy McCall ↶ |
430 |
Log { |
| d42369ab Andy McCall |
431 |
|
| c6aa5bd9 Andy McCall ↶ |
432 |
#[arg(long)] |
| 433 |
json: bool, |
| 434 |
}, |
| fce44ae9 Andy McCall ↶ |
435 |
} |
| 436 |
|
| 437 |
#[derive(Subcommand)] |
| 4e88e774 Andy McCall ↶ |
438 |
enum WorkspaceCmd { |
| 439 |
|
| d42369ab Andy McCall |
440 |
Add { |
| 441 |
|
| 442 |
path: PathBuf, |
| 443 |
|
| 444 |
changes: Vec<String>, |
| 445 |
}, |
| 446 |
|
| 1196b29b Andy McCall ↶ |
447 |
List { |
| d42369ab Andy McCall |
448 |
|
| 1196b29b Andy McCall ↶ |
449 |
#[arg(long)] |
| 450 |
json: bool, |
| 451 |
}, |
| 4e88e774 Andy McCall ↶ |
452 |
|
| d42369ab Andy McCall |
453 |
Forget { |
| 454 |
|
| 455 |
workspace: String, |
| 456 |
}, |
| 4e88e774 Andy McCall ↶ |
457 |
} |
| 458 |
|
| 459 |
#[derive(Subcommand)] |
| 957fee30 Andy McCall ↶ |
460 |
enum BisectCmd { |
| 461 |
|
| 462 |
Start, |
| 463 |
|
| d42369ab Andy McCall |
464 |
Good { |
| 465 |
|
| 466 |
changes: Vec<String>, |
| 467 |
}, |
| 957fee30 Andy McCall ↶ |
468 |
|
| d42369ab Andy McCall |
469 |
Bad { |
| 470 |
|
| 471 |
changes: Vec<String>, |
| 472 |
}, |
| 957fee30 Andy McCall ↶ |
473 |
|
| 474 |
Skip, |
| 475 |
|
| 476 |
Run { |
| d42369ab Andy McCall |
477 |
|
| 957fee30 Andy McCall ↶ |
478 |
#[arg(required = true, trailing_var_arg = true)] |
| 479 |
command: Vec<String>, |
| 480 |
}, |
| 481 |
|
| c6aa5bd9 Andy McCall ↶ |
482 |
Status { |
| d42369ab Andy McCall |
483 |
|
| c6aa5bd9 Andy McCall ↶ |
484 |
#[arg(long)] |
| 485 |
json: bool, |
| 486 |
}, |
| 957fee30 Andy McCall ↶ |
487 |
|
| 488 |
Reset, |
| 489 |
} |
| 490 |
|
| 491 |
#[derive(Subcommand)] |
| 7b9809e6 Andy McCall ↶ |
492 |
enum BookmarkCmd { |
| 493 |
|
| d42369ab Andy McCall |
494 |
Create { |
| 495 |
|
| 496 |
name: String, |
| 497 |
|
| 498 |
changes: Vec<String>, |
| 499 |
}, |
| 7b9809e6 Andy McCall ↶ |
500 |
|
| d42369ab Andy McCall |
501 |
Set { |
| 502 |
|
| 503 |
name: String, |
| 504 |
|
| 505 |
changes: Vec<String>, |
| 506 |
}, |
| 7b9809e6 Andy McCall ↶ |
507 |
|
| d42369ab Andy McCall |
508 |
Delete { |
| 509 |
|
| 510 |
name: String, |
| 511 |
}, |
| 7b9809e6 Andy McCall ↶ |
512 |
|
| c6aa5bd9 Andy McCall ↶ |
513 |
List { |
| d42369ab Andy McCall |
514 |
|
| c6aa5bd9 Andy McCall ↶ |
515 |
#[arg(long)] |
| 516 |
json: bool, |
| 517 |
}, |
| 61e3bce7 Andy McCall ↶ |
518 |
|
| 7b9809e6 Andy McCall ↶ |
519 |
Switch { |
| d42369ab Andy McCall |
520 |
|
| 7b9809e6 Andy McCall ↶ |
521 |
name: String, |
| 522 |
|
| 523 |
#[arg(long)] |
| 524 |
discard: bool, |
| 61e3bce7 Andy McCall ↶ |
525 |
|
| 526 |
|
| 527 |
#[arg(long, conflicts_with = "discard")] |
| 528 |
carry: bool, |
| 7b9809e6 Andy McCall ↶ |
529 |
}, |
| 530 |
} |
| 531 |
|
| 532 |
#[derive(Subcommand)] |
| 4dee277c Andy McCall ↶ |
533 |
enum SubmoduleCmd { |
| 534 |
|
| 535 |
Add { |
| d42369ab Andy McCall |
536 |
|
| 4dee277c Andy McCall ↶ |
537 |
url: String, |
| d42369ab Andy McCall |
538 |
|
| 4dee277c Andy McCall ↶ |
539 |
path: String, |
| 540 |
|
| 541 |
#[arg(long)] |
| 542 |
bookmark: Option<String>, |
| 543 |
}, |
| 544 |
|
| 545 |
Update { |
| 546 |
|
| 547 |
#[arg(long)] |
| 548 |
init: bool, |
| d42369ab Andy McCall |
549 |
|
| 4dee277c Andy McCall ↶ |
550 |
paths: Vec<String>, |
| 551 |
}, |
| 552 |
|
| c6aa5bd9 Andy McCall ↶ |
553 |
Status { |
| d42369ab Andy McCall |
554 |
|
| c6aa5bd9 Andy McCall ↶ |
555 |
#[arg(long)] |
| 556 |
json: bool, |
| 557 |
}, |
| 4dee277c Andy McCall ↶ |
558 |
|
| d42369ab Andy McCall |
559 |
Remove { |
| 560 |
|
| 561 |
path: String, |
| 562 |
}, |
| 4dee277c Andy McCall ↶ |
563 |
} |
| 564 |
|
| 565 |
#[derive(Subcommand)] |
| 132b884b Andy McCall ↶ |
566 |
enum TagCmd { |
| 567 |
|
| 568 |
Create { |
| d42369ab Andy McCall |
569 |
|
| 132b884b Andy McCall ↶ |
570 |
name: String, |
| d42369ab Andy McCall |
571 |
|
| 132b884b Andy McCall ↶ |
572 |
changes: Vec<String>, |
| d42369ab Andy McCall |
573 |
|
| 132b884b Andy McCall ↶ |
574 |
#[arg(short, long, default_value = "")] |
| 575 |
message: String, |
| 576 |
}, |
| d42369ab Andy McCall |
577 |
|
| 1196b29b Andy McCall ↶ |
578 |
List { |
| d42369ab Andy McCall |
579 |
|
| 1196b29b Andy McCall ↶ |
580 |
#[arg(long)] |
| 581 |
json: bool, |
| 582 |
}, |
| 132b884b Andy McCall ↶ |
583 |
} |
| 584 |
|
| 585 |
#[derive(Subcommand)] |
| fce44ae9 Andy McCall ↶ |
586 |
enum RemoteCmd { |
| d42369ab Andy McCall |
587 |
|
| 75167672 Andy McCall |
588 |
Add { |
| d42369ab Andy McCall |
589 |
|
| 75167672 Andy McCall |
590 |
name: String, |
| d42369ab Andy McCall |
591 |
|
| 75167672 Andy McCall |
592 |
url: String, |
| 593 |
}, |
| d42369ab Andy McCall |
594 |
|
| 75167672 Andy McCall |
595 |
Remove { |
| d42369ab Andy McCall |
596 |
|
| 75167672 Andy McCall |
597 |
name: String, |
| 598 |
}, |
| d42369ab Andy McCall |
599 |
|
| c6aa5bd9 Andy McCall ↶ |
600 |
List { |
| d42369ab Andy McCall |
601 |
|
| c6aa5bd9 Andy McCall ↶ |
602 |
#[arg(long)] |
| 603 |
json: bool, |
| 604 |
}, |
| fce44ae9 Andy McCall ↶ |
605 |
} |
| 606 |
|
| 607 |
#[derive(Subcommand)] |
| d82e4409 Andy McCall ↶ |
608 |
enum ProposalCmd { |
| 609 |
|
| 610 |
Show { |
| d42369ab Andy McCall |
611 |
|
| d82e4409 Andy McCall ↶ |
612 |
url: String, |
| d42369ab Andy McCall |
613 |
|
| d82e4409 Andy McCall ↶ |
614 |
#[arg(long)] |
| 615 |
json: bool, |
| 616 |
}, |
| 617 |
|
| 618 |
Land { |
| d42369ab Andy McCall |
619 |
|
| d82e4409 Andy McCall ↶ |
620 |
url: String, |
| 621 |
|
| 622 |
#[arg(long)] |
| 623 |
force: bool, |
| 624 |
}, |
| 625 |
} |
| 626 |
|
| 627 |
#[derive(Subcommand)] |
| fce44ae9 Andy McCall ↶ |
628 |
enum IdentityCmd { |
| 629 |
|
| 630 |
Create { |
| d42369ab Andy McCall |
631 |
|
| fce44ae9 Andy McCall ↶ |
632 |
#[arg(long)] |
| 633 |
name: Option<String>, |
| d42369ab Andy McCall |
634 |
|
| fce44ae9 Andy McCall ↶ |
635 |
#[arg(long)] |
| 636 |
email: Option<String>, |
| 637 |
|
| 638 |
#[arg(long)] |
| 639 |
local: bool, |
| 28fc23d7 Andy McCall ↶ |
640 |
|
| 641 |
#[arg(long)] |
| 642 |
expires: Option<u64>, |
| fce44ae9 Andy McCall ↶ |
643 |
}, |
| 644 |
|
| 645 |
Show, |
| 83e0677b Andy McCall ↶ |
646 |
|
| d42369ab Andy McCall |
647 |
Export { |
| e3d071ce Andy McCall ↶ |
648 |
|
| d42369ab Andy McCall |
649 |
path: Option<PathBuf>, |
| 650 |
}, |
| 7aa2dc93 Andy McCall ↶ |
651 |
|
| 652 |
SignChallenge { |
| d42369ab Andy McCall |
653 |
|
| 7aa2dc93 Andy McCall ↶ |
654 |
challenge: String, |
| d42369ab Andy McCall |
655 |
|
| 7aa2dc93 Andy McCall ↶ |
656 |
#[arg(long)] |
| 657 |
json: bool, |
| 658 |
}, |
| 28fc23d7 Andy McCall ↶ |
659 |
|
| 660 |
Rotate, |
| 661 |
|
| 662 |
Renew { |
| d42369ab Andy McCall |
663 |
|
| 28fc23d7 Andy McCall ↶ |
664 |
#[arg(long)] |
| 665 |
expires: u64, |
| 666 |
}, |
| 667 |
|
| 668 |
Revoke { |
| 669 |
|
| 670 |
key: Option<String>, |
| d42369ab Andy McCall |
671 |
|
| 28fc23d7 Andy McCall ↶ |
672 |
#[arg(long, default_value = "")] |
| 673 |
reason: String, |
| 674 |
}, |
| 675 |
|
| 676 |
Delegate { |
| 677 |
#[command(subcommand)] |
| 678 |
cmd: DelegateCmd, |
| 679 |
}, |
| 680 |
} |
| 681 |
|
| 682 |
#[derive(Subcommand)] |
| 683 |
enum DelegateCmd { |
| 684 |
|
| d42369ab Andy McCall |
685 |
Add { |
| 686 |
|
| 687 |
identity_file: PathBuf, |
| 688 |
}, |
| 28fc23d7 Andy McCall ↶ |
689 |
|
| d42369ab Andy McCall |
690 |
Remove { |
| 691 |
|
| 692 |
key: String, |
| 693 |
}, |
| 28fc23d7 Andy McCall ↶ |
694 |
|
| 695 |
List, |
| fce44ae9 Andy McCall ↶ |
696 |
} |
| 697 |
|
| 83e0677b Andy McCall ↶ |
698 |
#[derive(Subcommand)] |
| 79ab8528 Andy McCall ↶ |
699 |
enum GitCmd { |
| 700 |
|
| 30ea9c1e Andy McCall ↶ |
701 |
Export { |
| d42369ab Andy McCall |
702 |
|
| 30ea9c1e Andy McCall ↶ |
703 |
git_dir: PathBuf, |
| 704 |
|
| 705 |
#[arg(long)] |
| 706 |
branch: Option<String>, |
| 707 |
}, |
| 708 |
|
| 709 |
Fetch { |
| d42369ab Andy McCall |
710 |
|
| 30ea9c1e Andy McCall ↶ |
711 |
url: String, |
| d42369ab Andy McCall |
712 |
|
| 30ea9c1e Andy McCall ↶ |
713 |
#[arg(long, default_value = "main")] |
| 714 |
branch: String, |
| 715 |
}, |
| 716 |
|
| 717 |
Push { |
| d42369ab Andy McCall |
718 |
|
| 30ea9c1e Andy McCall ↶ |
719 |
url: String, |
| d42369ab Andy McCall |
720 |
|
| 30ea9c1e Andy McCall ↶ |
721 |
#[arg(long, default_value = "main")] |
| 722 |
branch: String, |
| 723 |
}, |
| 62794ecc Andy McCall ↶ |
724 |
|
| 725 |
Verify { |
| 726 |
|
| 727 |
git_dir: PathBuf, |
| 728 |
|
| 729 |
#[arg(long, default_value = "main")] |
| 730 |
branch: String, |
| 731 |
}, |
| c3069537 Andy McCall ↶ |
732 |
|
| 733 |
Import { |
| d42369ab Andy McCall |
734 |
|
| c3069537 Andy McCall ↶ |
735 |
git_dir: PathBuf, |
| d42369ab Andy McCall |
736 |
|
| c3069537 Andy McCall ↶ |
737 |
dest: PathBuf, |
| d42369ab Andy McCall |
738 |
|
| c3069537 Andy McCall ↶ |
739 |
#[arg(long, default_value = "main")] |
| 740 |
branch: String, |
| 741 |
}, |
| 79ab8528 Andy McCall ↶ |
742 |
} |
| 743 |
|
| 744 |
#[derive(Subcommand)] |
| 83e0677b Andy McCall ↶ |
745 |
enum PolicyCmd { |
| 746 |
|
| 747 |
Init, |
| 748 |
|
| c6aa5bd9 Andy McCall ↶ |
749 |
Show { |
| d42369ab Andy McCall |
750 |
|
| c6aa5bd9 Andy McCall ↶ |
751 |
#[arg(long)] |
| 752 |
json: bool, |
| 753 |
}, |
| 83e0677b Andy McCall ↶ |
754 |
|
| 755 |
Grant { |
| d42369ab Andy McCall |
756 |
|
| 83e0677b Andy McCall ↶ |
757 |
identity_file: PathBuf, |
| 758 |
|
| 759 |
#[arg(long)] |
| 760 |
pattern: Option<String>, |
| 28fc23d7 Andy McCall ↶ |
761 |
|
| 762 |
#[arg(long)] |
| 763 |
out: Option<PathBuf>, |
| 83e0677b Andy McCall ↶ |
764 |
}, |
| 765 |
|
| 28fc23d7 Andy McCall ↶ |
766 |
Revoke { |
| d42369ab Andy McCall |
767 |
|
| 28fc23d7 Andy McCall ↶ |
768 |
key: String, |
| 769 |
|
| 770 |
#[arg(long)] |
| 771 |
out: Option<PathBuf>, |
| 772 |
}, |
| 773 |
|
| 774 |
Root { |
| 775 |
#[command(subcommand)] |
| 776 |
cmd: RootCmd, |
| 777 |
}, |
| 778 |
|
| 779 |
Sign { |
| d42369ab Andy McCall |
780 |
|
| 28fc23d7 Andy McCall ↶ |
781 |
proposal: PathBuf, |
| 782 |
|
| 783 |
#[arg(long)] |
| 784 |
out: Option<PathBuf>, |
| 785 |
}, |
| 786 |
} |
| 787 |
|
| 788 |
#[derive(Subcommand)] |
| 789 |
enum RootCmd { |
| 790 |
|
| 791 |
Add { |
| d42369ab Andy McCall |
792 |
|
| 28fc23d7 Andy McCall ↶ |
793 |
identity_file: PathBuf, |
| d42369ab Andy McCall |
794 |
|
| 28fc23d7 Andy McCall ↶ |
795 |
#[arg(long)] |
| 796 |
out: Option<PathBuf>, |
| 797 |
}, |
| 798 |
|
| 799 |
Remove { |
| d42369ab Andy McCall |
800 |
|
| 28fc23d7 Andy McCall ↶ |
801 |
key: String, |
| d42369ab Andy McCall |
802 |
|
| 28fc23d7 Andy McCall ↶ |
803 |
#[arg(long)] |
| 804 |
out: Option<PathBuf>, |
| 805 |
}, |
| 806 |
|
| 807 |
Threshold { |
| d42369ab Andy McCall |
808 |
|
| 28fc23d7 Andy McCall ↶ |
809 |
n: u32, |
| d42369ab Andy McCall |
810 |
|
| 28fc23d7 Andy McCall ↶ |
811 |
#[arg(long)] |
| 812 |
out: Option<PathBuf>, |
| 813 |
}, |
| 83e0677b Andy McCall ↶ |
814 |
} |
| 815 |
|
| fce44ae9 Andy McCall ↶ |
816 |
|
| 817 |
fn open() -> Result<Repo> { |
| 818 |
Repo::open(&std::env::current_dir()?).context("opening repository") |
| 819 |
} |
| 820 |
|
| d42369ab Andy McCall |
821 |
|
| 822 |
fn man(dir: Option<PathBuf>) -> Result<i32> { |
| 823 |
use clap::CommandFactory; |
| 824 |
let cmd = Cli::command(); |
| 825 |
match dir { |
| 826 |
Some(dir) => { |
| 827 |
std::fs::create_dir_all(&dir)?; |
| 828 |
clap_mangen::generate_to(cmd, &dir)?; |
| 829 |
let pages = std::fs::read_dir(&dir)? |
| 830 |
.filter(|e| { |
| 831 |
e.as_ref() |
| 832 |
.is_ok_and(|e| e.path().extension().is_some_and(|x| x == "1")) |
| 833 |
}) |
| 834 |
.count(); |
| 835 |
println!( |
| 836 |
"{}", |
| 837 |
ui::done(format!("Wrote {pages} man pages to {}", dir.display())) |
| 838 |
); |
| 839 |
} |
| 840 |
None => clap_mangen::Man::new(cmd).render(&mut std::io::stdout())?, |
| 841 |
} |
| 842 |
Ok(0) |
| 843 |
} |
| 844 |
|
| fce44ae9 Andy McCall ↶ |
845 |
|
| 846 |
pub fn run() -> Result<i32> { |
| 847 |
let cli = Cli::parse(); |
| 135212de Andy McCall ↶ |
848 |
ui::init(cli.plain); |
| fce44ae9 Andy McCall ↶ |
849 |
match cli.cmd { |
| d42369ab Andy McCall |
850 |
Cmd::Completions { shell } => { |
| 851 |
use clap::CommandFactory; |
| 852 |
clap_complete::generate(shell, &mut Cli::command(), "oxy", &mut std::io::stdout()); |
| 853 |
Ok(0) |
| 854 |
} |
| 855 |
Cmd::Man { dir } => man(dir), |
| e02bf0cd Andy McCall ↶ |
856 |
Cmd::Init { path, bare } => workspace::init(path, bare), |
| 50a046e4 Andy McCall ↶ |
857 |
Cmd::Status { json } => workspace::status(json), |
| 75167672 Andy McCall |
858 |
Cmd::Prompt { |
| 859 |
format, |
| 860 |
glyphs, |
| 861 |
color, |
| 862 |
} => workspace::prompt(&format, glyphs, color.as_deref()), |
| 863 |
Cmd::Commit { |
| 864 |
message, |
| 865 |
depends_on, |
| 866 |
paths, |
| 867 |
interactive, |
| 868 |
hunks, |
| 869 |
} => workspace::commit(&message, &depends_on, &paths, interactive, &hunks), |
| c6aa5bd9 Andy McCall ↶ |
870 |
Cmd::Cat { path, change } => workspace::cat(&path, change.as_deref()), |
| 871 |
Cmd::Root { json } => workspace::root(json), |
| 872 |
Cmd::Version { json } => workspace::version(json), |
| 873 |
Cmd::Discard { paths, hunks } => workspace::discard(&paths, &hunks), |
| 874 |
Cmd::Hunks { json } => workspace::hunks(json), |
| 728da0f9 Andy McCall ↶ |
875 |
Cmd::Squash { change, into } => workspace::squash(&change, &into), |
| 876 |
Cmd::Rebase { change, onto } => workspace::rebase(&change, &onto), |
| 957fee30 Andy McCall ↶ |
877 |
Cmd::Blame { path, json } => workspace::blame(&path, json), |
| 878 |
Cmd::Bisect { cmd } => match cmd { |
| 879 |
BisectCmd::Start => workspace::bisect_start(), |
| 880 |
BisectCmd::Good { changes } => workspace::bisect_mark(Some(true), &changes), |
| 881 |
BisectCmd::Bad { changes } => workspace::bisect_mark(Some(false), &changes), |
| 882 |
BisectCmd::Skip => workspace::bisect_mark(None, &[]), |
| 883 |
BisectCmd::Run { command } => workspace::bisect_run(&command), |
| c6aa5bd9 Andy McCall ↶ |
884 |
BisectCmd::Status { json } => workspace::bisect_status(json), |
| 957fee30 Andy McCall ↶ |
885 |
BisectCmd::Reset => workspace::bisect_reset(), |
| 886 |
}, |
| 75167672 Andy McCall |
887 |
Cmd::Log { |
| 888 |
limit, |
| 889 |
verbose, |
| 890 |
path, |
| 891 |
json, |
| 892 |
} => workspace::log(limit, verbose, path.as_deref(), json), |
| c6aa5bd9 Andy McCall ↶ |
893 |
Cmd::Diff { change, json } => workspace::diff(change.as_deref(), json), |
| 614541c3 Andy McCall ↶ |
894 |
Cmd::Describe { message, change } => workspace::describe(&message, change.as_deref()), |
| 23b217d7 Andy McCall ↶ |
895 |
Cmd::Amend { message, into } => workspace::amend(message.as_deref(), into.as_deref()), |
| 896 |
Cmd::Split { change, paths } => workspace::split(&change, &paths), |
| 614541c3 Andy McCall ↶ |
897 |
Cmd::Abandon { change } => workspace::abandon(&change), |
| c6aa5bd9 Andy McCall ↶ |
898 |
Cmd::Show { change, json } => workspace::show(&change, json), |
| 1c2bd9ab Andy McCall ↶ |
899 |
Cmd::Checkout { |
| 900 |
changes, |
| 901 |
discard, |
| 902 |
carry, |
| 903 |
} => workspace::checkout(&changes, discard, carry), |
| c6aa5bd9 Andy McCall ↶ |
904 |
Cmd::Resolve { json } => workspace::resolve(json), |
| fce44ae9 Andy McCall ↶ |
905 |
Cmd::Undo => workspace::undo(), |
| ba160f60 Andy McCall ↶ |
906 |
Cmd::Gc { now } => workspace::gc(now), |
| 387335ff Andy McCall ↶ |
907 |
Cmd::Fsck { json } => workspace::fsck(json), |
| 3e5772cc Andy McCall ↶ |
908 |
Cmd::Doctor { offline, json } => workspace::doctor(offline, json), |
| 252e8cb2 Andy McCall ↶ |
909 |
Cmd::Checkpoint => workspace::checkpoint(), |
| 75167672 Andy McCall |
910 |
Cmd::Op { |
| 911 |
cmd: OpCmd::Log { json }, |
| 912 |
} => workspace::op_log(json), |
| 913 |
Cmd::Clone { |
| 914 |
url, |
| 915 |
dest, |
| 916 |
max_blob, |
| 917 |
sparse, |
| 918 |
depth, |
| 919 |
} => sync::clone(&url, dest, max_blob.as_deref(), &sparse, depth), |
| 2863456a Andy McCall ↶ |
920 |
Cmd::Deepen { depth, remote } => sync::deepen(&remote, depth), |
| 7421309f Andy McCall ↶ |
921 |
Cmd::Sparse { paths } => workspace::sparse(&paths), |
| cdb5beba Andy McCall ↶ |
922 |
Cmd::Lock { path } => workspace::lock(&path), |
| 923 |
Cmd::Unlock { path } => workspace::unlock(&path), |
| 4e88e774 Andy McCall ↶ |
924 |
Cmd::Workspace { cmd } => match cmd { |
| 925 |
WorkspaceCmd::Add { path, changes } => workspace::workspace_add(&path, &changes), |
| 1196b29b Andy McCall ↶ |
926 |
WorkspaceCmd::List { json } => workspace::workspace_list(json), |
| 4e88e774 Andy McCall ↶ |
927 |
WorkspaceCmd::Forget { workspace } => workspace::workspace_forget(&workspace), |
| 928 |
}, |
| 7b9809e6 Andy McCall ↶ |
929 |
Cmd::Bookmark { cmd } => match cmd { |
| 930 |
BookmarkCmd::Create { name, changes } => workspace::bookmark_create(&name, &changes), |
| 931 |
BookmarkCmd::Set { name, changes } => workspace::bookmark_set(&name, &changes), |
| 932 |
BookmarkCmd::Delete { name } => workspace::bookmark_delete(&name), |
| c6aa5bd9 Andy McCall ↶ |
933 |
BookmarkCmd::List { json } => workspace::bookmark_list(json), |
| 61e3bce7 Andy McCall ↶ |
934 |
BookmarkCmd::Switch { |
| 935 |
name, |
| 936 |
discard, |
| 937 |
carry, |
| 938 |
} => workspace::bookmark_switch(&name, discard, carry), |
| 7b9809e6 Andy McCall ↶ |
939 |
}, |
| 940 |
Cmd::Merge { bookmark } => workspace::merge(&bookmark), |
| 4dee277c Andy McCall ↶ |
941 |
Cmd::Submodule { cmd } => match cmd { |
| 75167672 Andy McCall |
942 |
SubmoduleCmd::Add { |
| 943 |
url, |
| 944 |
path, |
| 945 |
bookmark, |
| 946 |
} => sync::submodule_add(&url, &path, bookmark.as_deref()), |
| 4dee277c Andy McCall ↶ |
947 |
SubmoduleCmd::Update { init, paths } => sync::submodule_update(init, &paths), |
| c6aa5bd9 Andy McCall ↶ |
948 |
SubmoduleCmd::Status { json } => sync::submodule_status(json), |
| 4dee277c Andy McCall ↶ |
949 |
SubmoduleCmd::Remove { path } => sync::submodule_remove(&path), |
| 950 |
}, |
| 132b884b Andy McCall ↶ |
951 |
Cmd::Tag { cmd } => match cmd { |
| 75167672 Andy McCall |
952 |
TagCmd::Create { |
| 953 |
name, |
| 954 |
changes, |
| 955 |
message, |
| 956 |
} => workspace::tag_create(&name, &changes, &message), |
| 1196b29b Andy McCall ↶ |
957 |
TagCmd::List { json } => workspace::tag_list(json), |
| 132b884b Andy McCall ↶ |
958 |
}, |
| fce44ae9 Andy McCall ↶ |
959 |
Cmd::Remote { cmd } => match cmd { |
| 960 |
RemoteCmd::Add { name, url } => sync::remote_add(&name, &url), |
| 961 |
RemoteCmd::Remove { name } => sync::remote_remove(&name), |
| c6aa5bd9 Andy McCall ↶ |
962 |
RemoteCmd::List { json } => sync::remote_list(json), |
| fce44ae9 Andy McCall ↶ |
963 |
}, |
| c6aa5bd9 Andy McCall ↶ |
964 |
Cmd::Fetch { remote, json } => sync::fetch(remote.as_deref(), json), |
| 965 |
Cmd::Pull { remote, json } => sync::pull(remote.as_deref(), json), |
| 75167672 Andy McCall |
966 |
Cmd::Push { |
| 967 |
remote, |
| 968 |
force, |
| 969 |
bookmark, |
| 970 |
json, |
| 971 |
} => sync::push(remote.as_deref(), force, bookmark.as_deref(), json), |
| 972 |
Cmd::Serve { |
| 973 |
root, |
| 974 |
bind, |
| 975 |
tokens, |
| 976 |
tls_cert, |
| 977 |
tls_key, |
| 978 |
} => sync::serve(root, &bind, tokens, tls_cert.zip(tls_key)), |
| fce44ae9 Andy McCall ↶ |
979 |
Cmd::Identity { cmd } => match cmd { |
| 75167672 Andy McCall |
980 |
IdentityCmd::Create { |
| 981 |
name, |
| 982 |
email, |
| 983 |
local, |
| 984 |
expires, |
| 985 |
} => identity::create(name, email, local, expires), |
| fce44ae9 Andy McCall ↶ |
986 |
IdentityCmd::Show => identity::show(), |
| 83e0677b Andy McCall ↶ |
987 |
IdentityCmd::Export { path } => identity::export(path), |
| 119bbf50 Andy McCall ↶ |
988 |
IdentityCmd::SignChallenge { challenge, json } => { |
| 989 |
identity::sign_challenge(&challenge, json) |
| 990 |
} |
| 28fc23d7 Andy McCall ↶ |
991 |
IdentityCmd::Rotate => identity::rotate(), |
| 992 |
IdentityCmd::Renew { expires } => identity::renew(expires), |
| 993 |
IdentityCmd::Revoke { key, reason } => identity::revoke(key.as_deref(), &reason), |
| 994 |
IdentityCmd::Delegate { cmd } => match cmd { |
| 995 |
DelegateCmd::Add { identity_file } => identity::delegate_add(&identity_file), |
| 996 |
DelegateCmd::Remove { key } => identity::delegate_remove(&key), |
| 997 |
DelegateCmd::List => identity::delegate_list(), |
| 998 |
}, |
| 83e0677b Andy McCall ↶ |
999 |
}, |
| 75167672 Andy McCall |
1000 |
Cmd::Git { |
| 1001 |
cmd: GitCmd::Export { git_dir, branch }, |
| 1002 |
} => sync::git_export(&git_dir, branch.as_deref()), |
| 1003 |
Cmd::Git { |
| 1004 |
cmd: GitCmd::Fetch { url, branch }, |
| 1005 |
} => sync::git_fetch(&url, &branch), |
| 1006 |
Cmd::Git { |
| 1007 |
cmd: GitCmd::Push { url, branch }, |
| 1008 |
} => sync::git_push(&url, &branch), |
| 1009 |
Cmd::Git { |
| 1010 |
cmd: |
| 1011 |
GitCmd::Import { |
| 1012 |
git_dir, |
| 1013 |
dest, |
| 1014 |
branch, |
| 1015 |
}, |
| 1016 |
} => sync::git_import(&git_dir, &dest, &branch), |
| 62794ecc Andy McCall ↶ |
1017 |
Cmd::Git { |
| 1018 |
cmd: GitCmd::Verify { git_dir, branch }, |
| 1019 |
} => sync::git_verify(&git_dir, &branch), |
| 83e0677b Andy McCall ↶ |
1020 |
Cmd::Policy { cmd } => match cmd { |
| 1021 |
PolicyCmd::Init => identity::policy_init(), |
| c6aa5bd9 Andy McCall ↶ |
1022 |
PolicyCmd::Show { json } => identity::policy_show(json), |
| 75167672 Andy McCall |
1023 |
PolicyCmd::Grant { |
| 1024 |
identity_file, |
| 1025 |
pattern, |
| 1026 |
out, |
| 1027 |
} => identity::policy_grant(&identity_file, pattern.as_deref(), out), |
| 28fc23d7 Andy McCall ↶ |
1028 |
PolicyCmd::Revoke { key, out } => identity::policy_revoke(&key, out), |
| 1029 |
PolicyCmd::Root { cmd } => match cmd { |
| 75167672 Andy McCall |
1030 |
RootCmd::Add { identity_file, out } => { |
| 1031 |
identity::policy_root_add(&identity_file, out) |
| 1032 |
} |
| 28fc23d7 Andy McCall ↶ |
1033 |
RootCmd::Remove { key, out } => identity::policy_root_remove(&key, out), |
| 1034 |
RootCmd::Threshold { n, out } => identity::policy_threshold(n, out), |
| 1035 |
}, |
| 1036 |
PolicyCmd::Sign { proposal, out } => identity::policy_sign(&proposal, out), |
| fce44ae9 Andy McCall ↶ |
1037 |
}, |
| 4213c41d Andy McCall ↶ |
1038 |
Cmd::Seal { |
| 1039 |
changes, |
| 1040 |
proposal: Some(url), |
| 1041 |
json, |
| 1042 |
} if changes.is_empty() => proposal::seal(&url, json), |
| d82e4409 Andy McCall ↶ |
1043 |
Cmd::Seal { changes, json, .. } => identity::seal(&changes, json), |
| 1044 |
Cmd::Proposal { cmd } => match cmd { |
| 1045 |
ProposalCmd::Show { url, json } => proposal::show(&url, json), |
| 1046 |
ProposalCmd::Land { url, force } => proposal::land(&url, force), |
| 1047 |
}, |
| c6aa5bd9 Andy McCall ↶ |
1048 |
Cmd::Verify { change, json } => identity::verify(change.as_deref(), json), |
| fce44ae9 Andy McCall ↶ |
1049 |
Cmd::Config { key, value, user } => identity::config(&key, &value, user), |
| 1050 |
} |
| 1051 |
} |
| d42369ab Andy McCall |
1052 |
|
| 1053 |
#[cfg(test)] |
| 1054 |
mod help_tests { |
| 1055 |
use super::Cli; |
| 1056 |
use clap::CommandFactory; |
| 1057 |
|
| 1058 |
|
| 1059 |
|
| 1060 |
#[test] |
| 1061 |
fn every_command_and_argument_has_help() { |
| 1062 |
fn walk(cmd: &clap::Command, path: &str, missing: &mut Vec<String>) { |
| 1063 |
let here = format!("{path} {}", cmd.get_name()).trim().to_string(); |
| 1064 |
if cmd.get_about().is_none() && path != "" { |
| 1065 |
missing.push(format!("{here} (command)")); |
| 1066 |
} |
| 1067 |
for a in cmd.get_arguments() { |
| 1068 |
let id = a.get_id().as_str(); |
| 1069 |
if id == "help" || id == "version" || a.is_global_set() && path != "" { |
| 1070 |
continue; |
| 1071 |
} |
| 1072 |
if a.get_help().is_none() && a.get_long_help().is_none() { |
| 1073 |
missing.push(format!("{here} {id}")); |
| 1074 |
} |
| 1075 |
} |
| 1076 |
for sub in cmd.get_subcommands() { |
| 1077 |
walk(sub, &here, missing); |
| 1078 |
} |
| 1079 |
} |
| 1080 |
let mut missing = Vec::new(); |
| 1081 |
walk(&Cli::command(), "", &mut missing); |
| 1082 |
assert!( |
| 1083 |
missing.is_empty(), |
| 1084 |
"{} without help:\n{}", |
| 1085 |
missing.len(), |
| 1086 |
missing.join("\n") |
| 1087 |
); |
| 1088 |
} |
| 1089 |
} |