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