| 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", |
| e293c90d Andy McCall ↶ |
19 |
version = env!("OXY_VERSION_LONG"), |
| 75167672 Andy McCall |
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 { |
| 34 |
path: Option<PathBuf>, |
| 35 |
|
| 36 |
#[arg(long)] |
| 37 |
bare: bool, |
| 38 |
}, |
| fce44ae9 Andy McCall ↶ |
39 |
|
| b3c5a59a Andy McCall ↶ |
40 |
Clone { |
| 41 |
url: String, |
| 42 |
dest: Option<PathBuf>, |
| 43 |
|
| 44 |
#[arg(long)] |
| 45 |
max_blob: Option<String>, |
| 7421309f Andy McCall ↶ |
46 |
|
| 47 |
#[arg(long = "sparse")] |
| 48 |
sparse: Vec<String>, |
| 2863456a Andy McCall ↶ |
49 |
|
| 50 |
#[arg(long)] |
| 51 |
depth: Option<u32>, |
| b3c5a59a Andy McCall ↶ |
52 |
}, |
| 2863456a Andy McCall ↶ |
53 |
|
| 54 |
Deepen { |
| 55 |
#[arg(default_value_t = 10)] |
| 56 |
depth: u32, |
| 57 |
#[arg(long, default_value = "origin")] |
| 58 |
remote: String, |
| 59 |
}, |
| 7421309f Andy McCall ↶ |
60 |
|
| 61 |
Sparse { paths: Vec<String> }, |
| fce44ae9 Andy McCall ↶ |
62 |
|
| 50a046e4 Andy McCall ↶ |
63 |
Status { |
| 64 |
|
| 65 |
#[arg(long)] |
| 66 |
json: bool, |
| 67 |
}, |
| 135212de Andy McCall ↶ |
68 |
|
| 69 |
Prompt { |
| 694805cc Andy McCall ↶ |
70 |
|
| 135212de Andy McCall ↶ |
71 |
#[arg(long, default_value = oxy_core::repo::DEFAULT_PROMPT_FORMAT)] |
| 72 |
format: String, |
| 694805cc Andy McCall ↶ |
73 |
|
| 74 |
#[arg(long)] |
| 75 |
glyphs: bool, |
| 76 |
|
| 77 |
#[arg(long, value_parser = ["raw", "bash", "zsh"])] |
| 78 |
color: Option<String>, |
| 135212de Andy McCall ↶ |
79 |
}, |
| fce44ae9 Andy McCall ↶ |
80 |
|
| 81 |
Commit { |
| 82 |
#[arg(short, long)] |
| 83 |
message: String, |
| 84 |
|
| 85 |
#[arg(long = "depends-on")] |
| 86 |
depends_on: Vec<String>, |
| 957fee30 Andy McCall ↶ |
87 |
|
| 88 |
paths: Vec<String>, |
| 89 |
|
| 90 |
#[arg(short, long)] |
| 91 |
interactive: bool, |
| c6aa5bd9 Andy McCall ↶ |
92 |
|
| 93 |
#[arg(long, value_delimiter = ',')] |
| 94 |
hunks: Vec<usize>, |
| fce44ae9 Andy McCall ↶ |
95 |
}, |
| 728da0f9 Andy McCall ↶ |
96 |
|
| 97 |
Squash { |
| 98 |
change: String, |
| 99 |
#[arg(long)] |
| 100 |
into: String, |
| 101 |
}, |
| 102 |
|
| 103 |
Rebase { |
| 104 |
change: String, |
| 105 |
|
| 106 |
#[arg(long, required = true, num_args = 1..)] |
| 107 |
onto: Vec<String>, |
| 108 |
}, |
| 957fee30 Andy McCall ↶ |
109 |
|
| 110 |
Blame { |
| 111 |
path: String, |
| 112 |
#[arg(long)] |
| 113 |
json: bool, |
| 114 |
}, |
| 115 |
|
| 116 |
Bisect { |
| 117 |
#[command(subcommand)] |
| 118 |
cmd: BisectCmd, |
| 119 |
}, |
| fce44ae9 Andy McCall ↶ |
120 |
|
| 94084087 Andy McCall ↶ |
121 |
Log { |
| 122 |
|
| 123 |
#[arg(short = 'n', long)] |
| 124 |
limit: Option<usize>, |
| 125 |
|
| 126 |
#[arg(short, long)] |
| 127 |
verbose: bool, |
| c6aa5bd9 Andy McCall ↶ |
128 |
|
| 129 |
#[arg(long)] |
| 130 |
path: Option<String>, |
| 131 |
#[arg(long)] |
| 132 |
json: bool, |
| 94084087 Andy McCall ↶ |
133 |
}, |
| fce44ae9 Andy McCall ↶ |
134 |
|
| c6aa5bd9 Andy McCall ↶ |
135 |
Diff { |
| 136 |
|
| 137 |
change: Option<String>, |
| 138 |
#[arg(long)] |
| 139 |
json: bool, |
| 140 |
}, |
| 141 |
|
| 142 |
Cat { |
| 143 |
path: String, |
| 144 |
|
| 145 |
#[arg(short = 'r', long)] |
| 146 |
change: Option<String>, |
| 147 |
}, |
| 148 |
|
| 149 |
Root { |
| 150 |
#[arg(long)] |
| 151 |
json: bool, |
| 152 |
}, |
| 153 |
|
| 154 |
Version { |
| 155 |
#[arg(long)] |
| 156 |
json: bool, |
| 157 |
}, |
| 158 |
|
| 159 |
Discard { |
| 160 |
paths: Vec<String>, |
| 161 |
|
| 162 |
#[arg(long, value_delimiter = ',')] |
| 163 |
hunks: Vec<usize>, |
| 164 |
}, |
| 165 |
|
| 166 |
Hunks { |
| 167 |
#[arg(long)] |
| 168 |
json: bool, |
| 169 |
}, |
| 614541c3 Andy McCall ↶ |
170 |
|
| 171 |
Describe { |
| 172 |
#[arg(short, long)] |
| 173 |
message: String, |
| 174 |
change: Option<String>, |
| 175 |
}, |
| 23b217d7 Andy McCall ↶ |
176 |
|
| 614541c3 Andy McCall ↶ |
177 |
Amend { |
| 178 |
#[arg(short, long)] |
| 179 |
message: Option<String>, |
| 23b217d7 Andy McCall ↶ |
180 |
|
| 181 |
#[arg(long)] |
| 182 |
into: Option<String>, |
| 614541c3 Andy McCall ↶ |
183 |
}, |
| 23b217d7 Andy McCall ↶ |
184 |
|
| 75167672 Andy McCall |
185 |
Split { change: String, paths: Vec<String> }, |
| 614541c3 Andy McCall ↶ |
186 |
|
| 187 |
Abandon { change: String }, |
| fce44ae9 Andy McCall ↶ |
188 |
|
| c6aa5bd9 Andy McCall ↶ |
189 |
Show { |
| 190 |
change: String, |
| 191 |
#[arg(long)] |
| 192 |
json: bool, |
| 193 |
}, |
| fce44ae9 Andy McCall ↶ |
194 |
|
| 195 |
Checkout { |
| 196 |
changes: Vec<String>, |
| 197 |
|
| 198 |
#[arg(long)] |
| 199 |
discard: bool, |
| 200 |
}, |
| 201 |
|
| c6aa5bd9 Andy McCall ↶ |
202 |
Resolve { |
| 203 |
#[arg(long)] |
| 204 |
json: bool, |
| 205 |
}, |
| fce44ae9 Andy McCall ↶ |
206 |
|
| 207 |
Undo, |
| 252e8cb2 Andy McCall ↶ |
208 |
|
| 209 |
Checkpoint, |
| 3e5772cc Andy McCall ↶ |
210 |
|
| 211 |
Doctor { |
| 212 |
|
| 213 |
#[arg(long)] |
| 214 |
offline: bool, |
| 215 |
#[arg(long)] |
| 216 |
json: bool, |
| 217 |
}, |
| 387335ff Andy McCall ↶ |
218 |
|
| 219 |
Fsck { |
| 220 |
#[arg(long)] |
| 221 |
json: bool, |
| 222 |
}, |
| ba160f60 Andy McCall ↶ |
223 |
|
| 224 |
Gc { |
| 225 |
|
| 226 |
#[arg(long)] |
| 227 |
now: bool, |
| 228 |
}, |
| fce44ae9 Andy McCall ↶ |
229 |
|
| 230 |
#[command(name = "op")] |
| 231 |
Op { |
| 232 |
#[command(subcommand)] |
| 233 |
cmd: OpCmd, |
| 234 |
}, |
| cdb5beba Andy McCall ↶ |
235 |
|
| 236 |
Lock { path: String }, |
| 237 |
|
| 238 |
Unlock { path: String }, |
| 4e88e774 Andy McCall ↶ |
239 |
|
| 240 |
Workspace { |
| 241 |
#[command(subcommand)] |
| 242 |
cmd: WorkspaceCmd, |
| 243 |
}, |
| 7b9809e6 Andy McCall ↶ |
244 |
|
| 245 |
Bookmark { |
| 246 |
#[command(subcommand)] |
| 247 |
cmd: BookmarkCmd, |
| 248 |
}, |
| 249 |
|
| 250 |
Merge { bookmark: String }, |
| 4dee277c Andy McCall ↶ |
251 |
|
| 252 |
Submodule { |
| 253 |
#[command(subcommand)] |
| 254 |
cmd: SubmoduleCmd, |
| 255 |
}, |
| 132b884b Andy McCall ↶ |
256 |
|
| 257 |
Tag { |
| 258 |
#[command(subcommand)] |
| 259 |
cmd: TagCmd, |
| 260 |
}, |
| fce44ae9 Andy McCall ↶ |
261 |
|
| 262 |
Remote { |
| 263 |
#[command(subcommand)] |
| 264 |
cmd: RemoteCmd, |
| 265 |
}, |
| 266 |
|
| c6aa5bd9 Andy McCall ↶ |
267 |
Fetch { |
| 268 |
remote: Option<String>, |
| 269 |
#[arg(long)] |
| 270 |
json: bool, |
| 271 |
}, |
| fce44ae9 Andy McCall ↶ |
272 |
|
| c6aa5bd9 Andy McCall ↶ |
273 |
Pull { |
| 274 |
remote: Option<String>, |
| 275 |
#[arg(long)] |
| 276 |
json: bool, |
| 277 |
}, |
| fce44ae9 Andy McCall ↶ |
278 |
|
| 279 |
Push { |
| 280 |
remote: Option<String>, |
| 281 |
|
| 282 |
#[arg(long)] |
| 283 |
force: bool, |
| 7b9809e6 Andy McCall ↶ |
284 |
|
| 285 |
#[arg(short = 'b', long)] |
| 286 |
bookmark: Option<String>, |
| c6aa5bd9 Andy McCall ↶ |
287 |
#[arg(long)] |
| 288 |
json: bool, |
| fce44ae9 Andy McCall ↶ |
289 |
}, |
| 2b5ee371 Andy McCall ↶ |
290 |
|
| fce44ae9 Andy McCall ↶ |
291 |
Serve { |
| 292 |
|
| 293 |
#[arg(long, default_value = ".")] |
| 294 |
root: PathBuf, |
| 295 |
#[arg(long, default_value = "127.0.0.1:8890")] |
| 296 |
bind: String, |
| 297 |
|
| 298 |
#[arg(long = "token")] |
| 299 |
tokens: Vec<String>, |
| 2b5ee371 Andy McCall ↶ |
300 |
|
| 301 |
#[arg(long, requires = "tls_key")] |
| 302 |
tls_cert: Option<PathBuf>, |
| 303 |
|
| 304 |
#[arg(long, requires = "tls_cert")] |
| 305 |
tls_key: Option<PathBuf>, |
| fce44ae9 Andy McCall ↶ |
306 |
}, |
| 307 |
|
| 308 |
Identity { |
| 309 |
#[command(subcommand)] |
| 310 |
cmd: IdentityCmd, |
| 311 |
}, |
| 05e71ed6 Andy McCall ↶ |
312 |
|
| 313 |
Seal { |
| 314 |
changes: Vec<String>, |
| d82e4409 Andy McCall ↶ |
315 |
|
| 316 |
#[arg(long, conflicts_with = "changes")] |
| 317 |
proposal: Option<String>, |
| 05e71ed6 Andy McCall ↶ |
318 |
#[arg(long)] |
| 319 |
json: bool, |
| 320 |
}, |
| d82e4409 Andy McCall ↶ |
321 |
|
| 322 |
Proposal { |
| 323 |
#[command(subcommand)] |
| 324 |
cmd: ProposalCmd, |
| 325 |
}, |
| fce44ae9 Andy McCall ↶ |
326 |
|
| c6aa5bd9 Andy McCall ↶ |
327 |
Verify { |
| 328 |
change: Option<String>, |
| 329 |
#[arg(long)] |
| 330 |
json: bool, |
| 331 |
}, |
| 79ab8528 Andy McCall ↶ |
332 |
|
| 333 |
Git { |
| 334 |
#[command(subcommand)] |
| 335 |
cmd: GitCmd, |
| 336 |
}, |
| 83e0677b Andy McCall ↶ |
337 |
|
| 338 |
Policy { |
| 339 |
#[command(subcommand)] |
| 340 |
cmd: PolicyCmd, |
| 341 |
}, |
| 7421309f Andy McCall ↶ |
342 |
|
| fce44ae9 Andy McCall ↶ |
343 |
Config { |
| 344 |
key: String, |
| 345 |
value: String, |
| 346 |
|
| 347 |
#[arg(long)] |
| 348 |
user: bool, |
| 349 |
}, |
| 350 |
} |
| 351 |
|
| 352 |
#[derive(Subcommand)] |
| 353 |
enum OpCmd { |
| c6aa5bd9 Andy McCall ↶ |
354 |
Log { |
| 355 |
#[arg(long)] |
| 356 |
json: bool, |
| 357 |
}, |
| fce44ae9 Andy McCall ↶ |
358 |
} |
| 359 |
|
| 360 |
#[derive(Subcommand)] |
| 4e88e774 Andy McCall ↶ |
361 |
enum WorkspaceCmd { |
| 362 |
|
| 363 |
Add { path: PathBuf, changes: Vec<String> }, |
| 1196b29b Andy McCall ↶ |
364 |
List { |
| 365 |
#[arg(long)] |
| 366 |
json: bool, |
| 367 |
}, |
| 4e88e774 Andy McCall ↶ |
368 |
|
| 369 |
Forget { workspace: String }, |
| 370 |
} |
| 371 |
|
| 372 |
#[derive(Subcommand)] |
| 957fee30 Andy McCall ↶ |
373 |
enum BisectCmd { |
| 374 |
|
| 375 |
Start, |
| 376 |
|
| 377 |
Good { changes: Vec<String> }, |
| 378 |
|
| 379 |
Bad { changes: Vec<String> }, |
| 380 |
|
| 381 |
Skip, |
| 382 |
|
| 383 |
Run { |
| 384 |
#[arg(required = true, trailing_var_arg = true)] |
| 385 |
command: Vec<String>, |
| 386 |
}, |
| 387 |
|
| c6aa5bd9 Andy McCall ↶ |
388 |
Status { |
| 389 |
#[arg(long)] |
| 390 |
json: bool, |
| 391 |
}, |
| 957fee30 Andy McCall ↶ |
392 |
|
| 393 |
Reset, |
| 394 |
} |
| 395 |
|
| 396 |
#[derive(Subcommand)] |
| 7b9809e6 Andy McCall ↶ |
397 |
enum BookmarkCmd { |
| 398 |
|
| 399 |
Create { name: String, changes: Vec<String> }, |
| 400 |
|
| 401 |
Set { name: String, changes: Vec<String> }, |
| 402 |
|
| 403 |
Delete { name: String }, |
| 404 |
|
| c6aa5bd9 Andy McCall ↶ |
405 |
List { |
| 406 |
#[arg(long)] |
| 407 |
json: bool, |
| 408 |
}, |
| 7b9809e6 Andy McCall ↶ |
409 |
|
| 410 |
Switch { |
| 411 |
name: String, |
| 412 |
|
| 413 |
#[arg(long)] |
| 414 |
discard: bool, |
| 415 |
}, |
| 416 |
} |
| 417 |
|
| 418 |
#[derive(Subcommand)] |
| 4dee277c Andy McCall ↶ |
419 |
enum SubmoduleCmd { |
| 420 |
|
| 421 |
Add { |
| 422 |
url: String, |
| 423 |
path: String, |
| 424 |
|
| 425 |
#[arg(long)] |
| 426 |
bookmark: Option<String>, |
| 427 |
}, |
| 428 |
|
| 429 |
Update { |
| 430 |
|
| 431 |
#[arg(long)] |
| 432 |
init: bool, |
| 433 |
paths: Vec<String>, |
| 434 |
}, |
| 435 |
|
| c6aa5bd9 Andy McCall ↶ |
436 |
Status { |
| 437 |
#[arg(long)] |
| 438 |
json: bool, |
| 439 |
}, |
| 4dee277c Andy McCall ↶ |
440 |
|
| 441 |
Remove { path: String }, |
| 442 |
} |
| 443 |
|
| 444 |
#[derive(Subcommand)] |
| 132b884b Andy McCall ↶ |
445 |
enum TagCmd { |
| 446 |
|
| 447 |
Create { |
| 448 |
name: String, |
| 449 |
changes: Vec<String>, |
| 450 |
#[arg(short, long, default_value = "")] |
| 451 |
message: String, |
| 452 |
}, |
| 1196b29b Andy McCall ↶ |
453 |
List { |
| 454 |
#[arg(long)] |
| 455 |
json: bool, |
| 456 |
}, |
| 132b884b Andy McCall ↶ |
457 |
} |
| 458 |
|
| 459 |
#[derive(Subcommand)] |
| fce44ae9 Andy McCall ↶ |
460 |
enum RemoteCmd { |
| 75167672 Andy McCall |
461 |
Add { |
| 462 |
name: String, |
| 463 |
url: String, |
| 464 |
}, |
| 465 |
Remove { |
| 466 |
name: String, |
| 467 |
}, |
| c6aa5bd9 Andy McCall ↶ |
468 |
List { |
| 469 |
#[arg(long)] |
| 470 |
json: bool, |
| 471 |
}, |
| fce44ae9 Andy McCall ↶ |
472 |
} |
| 473 |
|
| 474 |
#[derive(Subcommand)] |
| d82e4409 Andy McCall ↶ |
475 |
enum ProposalCmd { |
| 476 |
|
| 477 |
Show { |
| 478 |
url: String, |
| 479 |
#[arg(long)] |
| 480 |
json: bool, |
| 481 |
}, |
| 482 |
|
| 483 |
Land { |
| 484 |
url: String, |
| 485 |
|
| 486 |
#[arg(long)] |
| 487 |
force: bool, |
| 488 |
}, |
| 489 |
} |
| 490 |
|
| 491 |
#[derive(Subcommand)] |
| fce44ae9 Andy McCall ↶ |
492 |
enum IdentityCmd { |
| 493 |
|
| 494 |
Create { |
| 495 |
#[arg(long)] |
| 496 |
name: Option<String>, |
| 497 |
#[arg(long)] |
| 498 |
email: Option<String>, |
| 499 |
|
| 500 |
#[arg(long)] |
| 501 |
local: bool, |
| 28fc23d7 Andy McCall ↶ |
502 |
|
| 503 |
#[arg(long)] |
| 504 |
expires: Option<u64>, |
| fce44ae9 Andy McCall ↶ |
505 |
}, |
| 506 |
|
| 507 |
Show, |
| 83e0677b Andy McCall ↶ |
508 |
|
| 509 |
Export { path: Option<PathBuf> }, |
| 7aa2dc93 Andy McCall ↶ |
510 |
|
| 511 |
SignChallenge { |
| 512 |
challenge: String, |
| 513 |
#[arg(long)] |
| 514 |
json: bool, |
| 515 |
}, |
| 28fc23d7 Andy McCall ↶ |
516 |
|
| 517 |
Rotate, |
| 518 |
|
| 519 |
Renew { |
| 520 |
#[arg(long)] |
| 521 |
expires: u64, |
| 522 |
}, |
| 523 |
|
| 524 |
Revoke { |
| 525 |
|
| 526 |
key: Option<String>, |
| 527 |
#[arg(long, default_value = "")] |
| 528 |
reason: String, |
| 529 |
}, |
| 530 |
|
| 531 |
Delegate { |
| 532 |
#[command(subcommand)] |
| 533 |
cmd: DelegateCmd, |
| 534 |
}, |
| 535 |
} |
| 536 |
|
| 537 |
#[derive(Subcommand)] |
| 538 |
enum DelegateCmd { |
| 539 |
|
| 540 |
Add { identity_file: PathBuf }, |
| 541 |
|
| 542 |
Remove { key: String }, |
| 543 |
|
| 544 |
List, |
| fce44ae9 Andy McCall ↶ |
545 |
} |
| 546 |
|
| 83e0677b Andy McCall ↶ |
547 |
#[derive(Subcommand)] |
| 79ab8528 Andy McCall ↶ |
548 |
enum GitCmd { |
| 549 |
|
| 30ea9c1e Andy McCall ↶ |
550 |
Export { |
| 551 |
git_dir: PathBuf, |
| 552 |
|
| 553 |
#[arg(long)] |
| 554 |
branch: Option<String>, |
| 555 |
}, |
| 556 |
|
| 557 |
Fetch { |
| 558 |
url: String, |
| 559 |
#[arg(long, default_value = "main")] |
| 560 |
branch: String, |
| 561 |
}, |
| 562 |
|
| 563 |
Push { |
| 564 |
url: String, |
| 565 |
#[arg(long, default_value = "main")] |
| 566 |
branch: String, |
| 567 |
}, |
| 62794ecc Andy McCall ↶ |
568 |
|
| 569 |
Verify { |
| 570 |
|
| 571 |
git_dir: PathBuf, |
| 572 |
|
| 573 |
#[arg(long, default_value = "main")] |
| 574 |
branch: String, |
| 575 |
}, |
| c3069537 Andy McCall ↶ |
576 |
|
| 577 |
Import { |
| 578 |
git_dir: PathBuf, |
| 579 |
dest: PathBuf, |
| 580 |
#[arg(long, default_value = "main")] |
| 581 |
branch: String, |
| 582 |
}, |
| 79ab8528 Andy McCall ↶ |
583 |
} |
| 584 |
|
| 585 |
#[derive(Subcommand)] |
| 83e0677b Andy McCall ↶ |
586 |
enum PolicyCmd { |
| 587 |
|
| 588 |
Init, |
| 589 |
|
| c6aa5bd9 Andy McCall ↶ |
590 |
Show { |
| 591 |
#[arg(long)] |
| 592 |
json: bool, |
| 593 |
}, |
| 83e0677b Andy McCall ↶ |
594 |
|
| 595 |
Grant { |
| 596 |
identity_file: PathBuf, |
| 597 |
|
| 598 |
#[arg(long)] |
| 599 |
pattern: Option<String>, |
| 28fc23d7 Andy McCall ↶ |
600 |
|
| 601 |
#[arg(long)] |
| 602 |
out: Option<PathBuf>, |
| 83e0677b Andy McCall ↶ |
603 |
}, |
| 604 |
|
| 28fc23d7 Andy McCall ↶ |
605 |
Revoke { |
| 606 |
key: String, |
| 607 |
|
| 608 |
#[arg(long)] |
| 609 |
out: Option<PathBuf>, |
| 610 |
}, |
| 611 |
|
| 612 |
Root { |
| 613 |
#[command(subcommand)] |
| 614 |
cmd: RootCmd, |
| 615 |
}, |
| 616 |
|
| 617 |
Sign { |
| 618 |
proposal: PathBuf, |
| 619 |
|
| 620 |
#[arg(long)] |
| 621 |
out: Option<PathBuf>, |
| 622 |
}, |
| 623 |
} |
| 624 |
|
| 625 |
#[derive(Subcommand)] |
| 626 |
enum RootCmd { |
| 627 |
|
| 628 |
Add { |
| 629 |
identity_file: PathBuf, |
| 630 |
#[arg(long)] |
| 631 |
out: Option<PathBuf>, |
| 632 |
}, |
| 633 |
|
| 634 |
Remove { |
| 635 |
key: String, |
| 636 |
#[arg(long)] |
| 637 |
out: Option<PathBuf>, |
| 638 |
}, |
| 639 |
|
| 640 |
Threshold { |
| 641 |
n: u32, |
| 642 |
#[arg(long)] |
| 643 |
out: Option<PathBuf>, |
| 644 |
}, |
| 83e0677b Andy McCall ↶ |
645 |
} |
| 646 |
|
| fce44ae9 Andy McCall ↶ |
647 |
|
| 648 |
fn open() -> Result<Repo> { |
| 649 |
Repo::open(&std::env::current_dir()?).context("opening repository") |
| 650 |
} |
| 651 |
|
| 652 |
|
| 653 |
pub fn run() -> Result<i32> { |
| 654 |
let cli = Cli::parse(); |
| 135212de Andy McCall ↶ |
655 |
ui::init(cli.plain); |
| fce44ae9 Andy McCall ↶ |
656 |
match cli.cmd { |
| e02bf0cd Andy McCall ↶ |
657 |
Cmd::Init { path, bare } => workspace::init(path, bare), |
| 50a046e4 Andy McCall ↶ |
658 |
Cmd::Status { json } => workspace::status(json), |
| 75167672 Andy McCall |
659 |
Cmd::Prompt { |
| 660 |
format, |
| 661 |
glyphs, |
| 662 |
color, |
| 663 |
} => workspace::prompt(&format, glyphs, color.as_deref()), |
| 664 |
Cmd::Commit { |
| 665 |
message, |
| 666 |
depends_on, |
| 667 |
paths, |
| 668 |
interactive, |
| 669 |
hunks, |
| 670 |
} => workspace::commit(&message, &depends_on, &paths, interactive, &hunks), |
| c6aa5bd9 Andy McCall ↶ |
671 |
Cmd::Cat { path, change } => workspace::cat(&path, change.as_deref()), |
| 672 |
Cmd::Root { json } => workspace::root(json), |
| 673 |
Cmd::Version { json } => workspace::version(json), |
| 674 |
Cmd::Discard { paths, hunks } => workspace::discard(&paths, &hunks), |
| 675 |
Cmd::Hunks { json } => workspace::hunks(json), |
| 728da0f9 Andy McCall ↶ |
676 |
Cmd::Squash { change, into } => workspace::squash(&change, &into), |
| 677 |
Cmd::Rebase { change, onto } => workspace::rebase(&change, &onto), |
| 957fee30 Andy McCall ↶ |
678 |
Cmd::Blame { path, json } => workspace::blame(&path, json), |
| 679 |
Cmd::Bisect { cmd } => match cmd { |
| 680 |
BisectCmd::Start => workspace::bisect_start(), |
| 681 |
BisectCmd::Good { changes } => workspace::bisect_mark(Some(true), &changes), |
| 682 |
BisectCmd::Bad { changes } => workspace::bisect_mark(Some(false), &changes), |
| 683 |
BisectCmd::Skip => workspace::bisect_mark(None, &[]), |
| 684 |
BisectCmd::Run { command } => workspace::bisect_run(&command), |
| c6aa5bd9 Andy McCall ↶ |
685 |
BisectCmd::Status { json } => workspace::bisect_status(json), |
| 957fee30 Andy McCall ↶ |
686 |
BisectCmd::Reset => workspace::bisect_reset(), |
| 687 |
}, |
| 75167672 Andy McCall |
688 |
Cmd::Log { |
| 689 |
limit, |
| 690 |
verbose, |
| 691 |
path, |
| 692 |
json, |
| 693 |
} => workspace::log(limit, verbose, path.as_deref(), json), |
| c6aa5bd9 Andy McCall ↶ |
694 |
Cmd::Diff { change, json } => workspace::diff(change.as_deref(), json), |
| 614541c3 Andy McCall ↶ |
695 |
Cmd::Describe { message, change } => workspace::describe(&message, change.as_deref()), |
| 23b217d7 Andy McCall ↶ |
696 |
Cmd::Amend { message, into } => workspace::amend(message.as_deref(), into.as_deref()), |
| 697 |
Cmd::Split { change, paths } => workspace::split(&change, &paths), |
| 614541c3 Andy McCall ↶ |
698 |
Cmd::Abandon { change } => workspace::abandon(&change), |
| c6aa5bd9 Andy McCall ↶ |
699 |
Cmd::Show { change, json } => workspace::show(&change, json), |
| fce44ae9 Andy McCall ↶ |
700 |
Cmd::Checkout { changes, discard } => workspace::checkout(&changes, discard), |
| c6aa5bd9 Andy McCall ↶ |
701 |
Cmd::Resolve { json } => workspace::resolve(json), |
| fce44ae9 Andy McCall ↶ |
702 |
Cmd::Undo => workspace::undo(), |
| ba160f60 Andy McCall ↶ |
703 |
Cmd::Gc { now } => workspace::gc(now), |
| 387335ff Andy McCall ↶ |
704 |
Cmd::Fsck { json } => workspace::fsck(json), |
| 3e5772cc Andy McCall ↶ |
705 |
Cmd::Doctor { offline, json } => workspace::doctor(offline, json), |
| 252e8cb2 Andy McCall ↶ |
706 |
Cmd::Checkpoint => workspace::checkpoint(), |
| 75167672 Andy McCall |
707 |
Cmd::Op { |
| 708 |
cmd: OpCmd::Log { json }, |
| 709 |
} => workspace::op_log(json), |
| 710 |
Cmd::Clone { |
| 711 |
url, |
| 712 |
dest, |
| 713 |
max_blob, |
| 714 |
sparse, |
| 715 |
depth, |
| 716 |
} => sync::clone(&url, dest, max_blob.as_deref(), &sparse, depth), |
| 2863456a Andy McCall ↶ |
717 |
Cmd::Deepen { depth, remote } => sync::deepen(&remote, depth), |
| 7421309f Andy McCall ↶ |
718 |
Cmd::Sparse { paths } => workspace::sparse(&paths), |
| cdb5beba Andy McCall ↶ |
719 |
Cmd::Lock { path } => workspace::lock(&path), |
| 720 |
Cmd::Unlock { path } => workspace::unlock(&path), |
| 4e88e774 Andy McCall ↶ |
721 |
Cmd::Workspace { cmd } => match cmd { |
| 722 |
WorkspaceCmd::Add { path, changes } => workspace::workspace_add(&path, &changes), |
| 1196b29b Andy McCall ↶ |
723 |
WorkspaceCmd::List { json } => workspace::workspace_list(json), |
| 4e88e774 Andy McCall ↶ |
724 |
WorkspaceCmd::Forget { workspace } => workspace::workspace_forget(&workspace), |
| 725 |
}, |
| 7b9809e6 Andy McCall ↶ |
726 |
Cmd::Bookmark { cmd } => match cmd { |
| 727 |
BookmarkCmd::Create { name, changes } => workspace::bookmark_create(&name, &changes), |
| 728 |
BookmarkCmd::Set { name, changes } => workspace::bookmark_set(&name, &changes), |
| 729 |
BookmarkCmd::Delete { name } => workspace::bookmark_delete(&name), |
| c6aa5bd9 Andy McCall ↶ |
730 |
BookmarkCmd::List { json } => workspace::bookmark_list(json), |
| 7b9809e6 Andy McCall ↶ |
731 |
BookmarkCmd::Switch { name, discard } => workspace::bookmark_switch(&name, discard), |
| 732 |
}, |
| 733 |
Cmd::Merge { bookmark } => workspace::merge(&bookmark), |
| 4dee277c Andy McCall ↶ |
734 |
Cmd::Submodule { cmd } => match cmd { |
| 75167672 Andy McCall |
735 |
SubmoduleCmd::Add { |
| 736 |
url, |
| 737 |
path, |
| 738 |
bookmark, |
| 739 |
} => sync::submodule_add(&url, &path, bookmark.as_deref()), |
| 4dee277c Andy McCall ↶ |
740 |
SubmoduleCmd::Update { init, paths } => sync::submodule_update(init, &paths), |
| c6aa5bd9 Andy McCall ↶ |
741 |
SubmoduleCmd::Status { json } => sync::submodule_status(json), |
| 4dee277c Andy McCall ↶ |
742 |
SubmoduleCmd::Remove { path } => sync::submodule_remove(&path), |
| 743 |
}, |
| 132b884b Andy McCall ↶ |
744 |
Cmd::Tag { cmd } => match cmd { |
| 75167672 Andy McCall |
745 |
TagCmd::Create { |
| 746 |
name, |
| 747 |
changes, |
| 748 |
message, |
| 749 |
} => workspace::tag_create(&name, &changes, &message), |
| 1196b29b Andy McCall ↶ |
750 |
TagCmd::List { json } => workspace::tag_list(json), |
| 132b884b Andy McCall ↶ |
751 |
}, |
| fce44ae9 Andy McCall ↶ |
752 |
Cmd::Remote { cmd } => match cmd { |
| 753 |
RemoteCmd::Add { name, url } => sync::remote_add(&name, &url), |
| 754 |
RemoteCmd::Remove { name } => sync::remote_remove(&name), |
| c6aa5bd9 Andy McCall ↶ |
755 |
RemoteCmd::List { json } => sync::remote_list(json), |
| fce44ae9 Andy McCall ↶ |
756 |
}, |
| c6aa5bd9 Andy McCall ↶ |
757 |
Cmd::Fetch { remote, json } => sync::fetch(remote.as_deref(), json), |
| 758 |
Cmd::Pull { remote, json } => sync::pull(remote.as_deref(), json), |
| 75167672 Andy McCall |
759 |
Cmd::Push { |
| 760 |
remote, |
| 761 |
force, |
| 762 |
bookmark, |
| 763 |
json, |
| 764 |
} => sync::push(remote.as_deref(), force, bookmark.as_deref(), json), |
| 765 |
Cmd::Serve { |
| 766 |
root, |
| 767 |
bind, |
| 768 |
tokens, |
| 769 |
tls_cert, |
| 770 |
tls_key, |
| 771 |
} => sync::serve(root, &bind, tokens, tls_cert.zip(tls_key)), |
| fce44ae9 Andy McCall ↶ |
772 |
Cmd::Identity { cmd } => match cmd { |
| 75167672 Andy McCall |
773 |
IdentityCmd::Create { |
| 774 |
name, |
| 775 |
email, |
| 776 |
local, |
| 777 |
expires, |
| 778 |
} => identity::create(name, email, local, expires), |
| fce44ae9 Andy McCall ↶ |
779 |
IdentityCmd::Show => identity::show(), |
| 83e0677b Andy McCall ↶ |
780 |
IdentityCmd::Export { path } => identity::export(path), |
| 119bbf50 Andy McCall ↶ |
781 |
IdentityCmd::SignChallenge { challenge, json } => { |
| 782 |
identity::sign_challenge(&challenge, json) |
| 783 |
} |
| 28fc23d7 Andy McCall ↶ |
784 |
IdentityCmd::Rotate => identity::rotate(), |
| 785 |
IdentityCmd::Renew { expires } => identity::renew(expires), |
| 786 |
IdentityCmd::Revoke { key, reason } => identity::revoke(key.as_deref(), &reason), |
| 787 |
IdentityCmd::Delegate { cmd } => match cmd { |
| 788 |
DelegateCmd::Add { identity_file } => identity::delegate_add(&identity_file), |
| 789 |
DelegateCmd::Remove { key } => identity::delegate_remove(&key), |
| 790 |
DelegateCmd::List => identity::delegate_list(), |
| 791 |
}, |
| 83e0677b Andy McCall ↶ |
792 |
}, |
| 75167672 Andy McCall |
793 |
Cmd::Git { |
| 794 |
cmd: GitCmd::Export { git_dir, branch }, |
| 795 |
} => sync::git_export(&git_dir, branch.as_deref()), |
| 796 |
Cmd::Git { |
| 797 |
cmd: GitCmd::Fetch { url, branch }, |
| 798 |
} => sync::git_fetch(&url, &branch), |
| 799 |
Cmd::Git { |
| 800 |
cmd: GitCmd::Push { url, branch }, |
| 801 |
} => sync::git_push(&url, &branch), |
| 802 |
Cmd::Git { |
| 803 |
cmd: |
| 804 |
GitCmd::Import { |
| 805 |
git_dir, |
| 806 |
dest, |
| 807 |
branch, |
| 808 |
}, |
| 809 |
} => sync::git_import(&git_dir, &dest, &branch), |
| 62794ecc Andy McCall ↶ |
810 |
Cmd::Git { |
| 811 |
cmd: GitCmd::Verify { git_dir, branch }, |
| 812 |
} => sync::git_verify(&git_dir, &branch), |
| 83e0677b Andy McCall ↶ |
813 |
Cmd::Policy { cmd } => match cmd { |
| 814 |
PolicyCmd::Init => identity::policy_init(), |
| c6aa5bd9 Andy McCall ↶ |
815 |
PolicyCmd::Show { json } => identity::policy_show(json), |
| 75167672 Andy McCall |
816 |
PolicyCmd::Grant { |
| 817 |
identity_file, |
| 818 |
pattern, |
| 819 |
out, |
| 820 |
} => identity::policy_grant(&identity_file, pattern.as_deref(), out), |
| 28fc23d7 Andy McCall ↶ |
821 |
PolicyCmd::Revoke { key, out } => identity::policy_revoke(&key, out), |
| 822 |
PolicyCmd::Root { cmd } => match cmd { |
| 75167672 Andy McCall |
823 |
RootCmd::Add { identity_file, out } => { |
| 824 |
identity::policy_root_add(&identity_file, out) |
| 825 |
} |
| 28fc23d7 Andy McCall ↶ |
826 |
RootCmd::Remove { key, out } => identity::policy_root_remove(&key, out), |
| 827 |
RootCmd::Threshold { n, out } => identity::policy_threshold(n, out), |
| 828 |
}, |
| 829 |
PolicyCmd::Sign { proposal, out } => identity::policy_sign(&proposal, out), |
| fce44ae9 Andy McCall ↶ |
830 |
}, |
| 4213c41d Andy McCall ↶ |
831 |
Cmd::Seal { |
| 832 |
changes, |
| 833 |
proposal: Some(url), |
| 834 |
json, |
| 835 |
} if changes.is_empty() => proposal::seal(&url, json), |
| d82e4409 Andy McCall ↶ |
836 |
Cmd::Seal { changes, json, .. } => identity::seal(&changes, json), |
| 837 |
Cmd::Proposal { cmd } => match cmd { |
| 838 |
ProposalCmd::Show { url, json } => proposal::show(&url, json), |
| 839 |
ProposalCmd::Land { url, force } => proposal::land(&url, force), |
| 840 |
}, |
| c6aa5bd9 Andy McCall ↶ |
841 |
Cmd::Verify { change, json } => identity::verify(change.as_deref(), json), |
| fce44ae9 Andy McCall ↶ |
842 |
Cmd::Config { key, value, user } => identity::config(&key, &value, user), |
| 843 |
} |
| 844 |
} |