| 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 { |
| 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, |
| ba160f60 Andy McCall ↶ |
210 |
|
| 211 |
Gc { |
| 212 |
|
| 213 |
#[arg(long)] |
| 214 |
now: bool, |
| 215 |
}, |
| fce44ae9 Andy McCall ↶ |
216 |
|
| 217 |
#[command(name = "op")] |
| 218 |
Op { |
| 219 |
#[command(subcommand)] |
| 220 |
cmd: OpCmd, |
| 221 |
}, |
| cdb5beba Andy McCall ↶ |
222 |
|
| 223 |
Lock { path: String }, |
| 224 |
|
| 225 |
Unlock { path: String }, |
| 4e88e774 Andy McCall ↶ |
226 |
|
| 227 |
Workspace { |
| 228 |
#[command(subcommand)] |
| 229 |
cmd: WorkspaceCmd, |
| 230 |
}, |
| 7b9809e6 Andy McCall ↶ |
231 |
|
| 232 |
Bookmark { |
| 233 |
#[command(subcommand)] |
| 234 |
cmd: BookmarkCmd, |
| 235 |
}, |
| 236 |
|
| 237 |
Merge { bookmark: String }, |
| 4dee277c Andy McCall ↶ |
238 |
|
| 239 |
Submodule { |
| 240 |
#[command(subcommand)] |
| 241 |
cmd: SubmoduleCmd, |
| 242 |
}, |
| 132b884b Andy McCall ↶ |
243 |
|
| 244 |
Tag { |
| 245 |
#[command(subcommand)] |
| 246 |
cmd: TagCmd, |
| 247 |
}, |
| fce44ae9 Andy McCall ↶ |
248 |
|
| 249 |
Remote { |
| 250 |
#[command(subcommand)] |
| 251 |
cmd: RemoteCmd, |
| 252 |
}, |
| 253 |
|
| c6aa5bd9 Andy McCall ↶ |
254 |
Fetch { |
| 255 |
remote: Option<String>, |
| 256 |
#[arg(long)] |
| 257 |
json: bool, |
| 258 |
}, |
| fce44ae9 Andy McCall ↶ |
259 |
|
| c6aa5bd9 Andy McCall ↶ |
260 |
Pull { |
| 261 |
remote: Option<String>, |
| 262 |
#[arg(long)] |
| 263 |
json: bool, |
| 264 |
}, |
| fce44ae9 Andy McCall ↶ |
265 |
|
| 266 |
Push { |
| 267 |
remote: Option<String>, |
| 268 |
|
| 269 |
#[arg(long)] |
| 270 |
force: bool, |
| 7b9809e6 Andy McCall ↶ |
271 |
|
| 272 |
#[arg(short = 'b', long)] |
| 273 |
bookmark: Option<String>, |
| c6aa5bd9 Andy McCall ↶ |
274 |
#[arg(long)] |
| 275 |
json: bool, |
| fce44ae9 Andy McCall ↶ |
276 |
}, |
| 2b5ee371 Andy McCall ↶ |
277 |
|
| fce44ae9 Andy McCall ↶ |
278 |
Serve { |
| 279 |
|
| 280 |
#[arg(long, default_value = ".")] |
| 281 |
root: PathBuf, |
| 282 |
#[arg(long, default_value = "127.0.0.1:8890")] |
| 283 |
bind: String, |
| 284 |
|
| 285 |
#[arg(long = "token")] |
| 286 |
tokens: Vec<String>, |
| 2b5ee371 Andy McCall ↶ |
287 |
|
| 288 |
#[arg(long, requires = "tls_key")] |
| 289 |
tls_cert: Option<PathBuf>, |
| 290 |
|
| 291 |
#[arg(long, requires = "tls_cert")] |
| 292 |
tls_key: Option<PathBuf>, |
| fce44ae9 Andy McCall ↶ |
293 |
}, |
| 294 |
|
| 295 |
Identity { |
| 296 |
#[command(subcommand)] |
| 297 |
cmd: IdentityCmd, |
| 298 |
}, |
| 05e71ed6 Andy McCall ↶ |
299 |
|
| 300 |
Seal { |
| 301 |
changes: Vec<String>, |
| d82e4409 Andy McCall ↶ |
302 |
|
| 303 |
#[arg(long, conflicts_with = "changes")] |
| 304 |
proposal: Option<String>, |
| 05e71ed6 Andy McCall ↶ |
305 |
#[arg(long)] |
| 306 |
json: bool, |
| 307 |
}, |
| d82e4409 Andy McCall ↶ |
308 |
|
| 309 |
Proposal { |
| 310 |
#[command(subcommand)] |
| 311 |
cmd: ProposalCmd, |
| 312 |
}, |
| fce44ae9 Andy McCall ↶ |
313 |
|
| c6aa5bd9 Andy McCall ↶ |
314 |
Verify { |
| 315 |
change: Option<String>, |
| 316 |
#[arg(long)] |
| 317 |
json: bool, |
| 318 |
}, |
| 79ab8528 Andy McCall ↶ |
319 |
|
| 320 |
Git { |
| 321 |
#[command(subcommand)] |
| 322 |
cmd: GitCmd, |
| 323 |
}, |
| 83e0677b Andy McCall ↶ |
324 |
|
| 325 |
Policy { |
| 326 |
#[command(subcommand)] |
| 327 |
cmd: PolicyCmd, |
| 328 |
}, |
| 7421309f Andy McCall ↶ |
329 |
|
| fce44ae9 Andy McCall ↶ |
330 |
Config { |
| 331 |
key: String, |
| 332 |
value: String, |
| 333 |
|
| 334 |
#[arg(long)] |
| 335 |
user: bool, |
| 336 |
}, |
| 337 |
} |
| 338 |
|
| 339 |
#[derive(Subcommand)] |
| 340 |
enum OpCmd { |
| c6aa5bd9 Andy McCall ↶ |
341 |
Log { |
| 342 |
#[arg(long)] |
| 343 |
json: bool, |
| 344 |
}, |
| fce44ae9 Andy McCall ↶ |
345 |
} |
| 346 |
|
| 347 |
#[derive(Subcommand)] |
| 4e88e774 Andy McCall ↶ |
348 |
enum WorkspaceCmd { |
| 349 |
|
| 350 |
Add { path: PathBuf, changes: Vec<String> }, |
| 1196b29b Andy McCall ↶ |
351 |
List { |
| 352 |
#[arg(long)] |
| 353 |
json: bool, |
| 354 |
}, |
| 4e88e774 Andy McCall ↶ |
355 |
|
| 356 |
Forget { workspace: String }, |
| 357 |
} |
| 358 |
|
| 359 |
#[derive(Subcommand)] |
| 957fee30 Andy McCall ↶ |
360 |
enum BisectCmd { |
| 361 |
|
| 362 |
Start, |
| 363 |
|
| 364 |
Good { changes: Vec<String> }, |
| 365 |
|
| 366 |
Bad { changes: Vec<String> }, |
| 367 |
|
| 368 |
Skip, |
| 369 |
|
| 370 |
Run { |
| 371 |
#[arg(required = true, trailing_var_arg = true)] |
| 372 |
command: Vec<String>, |
| 373 |
}, |
| 374 |
|
| c6aa5bd9 Andy McCall ↶ |
375 |
Status { |
| 376 |
#[arg(long)] |
| 377 |
json: bool, |
| 378 |
}, |
| 957fee30 Andy McCall ↶ |
379 |
|
| 380 |
Reset, |
| 381 |
} |
| 382 |
|
| 383 |
#[derive(Subcommand)] |
| 7b9809e6 Andy McCall ↶ |
384 |
enum BookmarkCmd { |
| 385 |
|
| 386 |
Create { name: String, changes: Vec<String> }, |
| 387 |
|
| 388 |
Set { name: String, changes: Vec<String> }, |
| 389 |
|
| 390 |
Delete { name: String }, |
| 391 |
|
| c6aa5bd9 Andy McCall ↶ |
392 |
List { |
| 393 |
#[arg(long)] |
| 394 |
json: bool, |
| 395 |
}, |
| 7b9809e6 Andy McCall ↶ |
396 |
|
| 397 |
Switch { |
| 398 |
name: String, |
| 399 |
|
| 400 |
#[arg(long)] |
| 401 |
discard: bool, |
| 402 |
}, |
| 403 |
} |
| 404 |
|
| 405 |
#[derive(Subcommand)] |
| 4dee277c Andy McCall ↶ |
406 |
enum SubmoduleCmd { |
| 407 |
|
| 408 |
Add { |
| 409 |
url: String, |
| 410 |
path: String, |
| 411 |
|
| 412 |
#[arg(long)] |
| 413 |
bookmark: Option<String>, |
| 414 |
}, |
| 415 |
|
| 416 |
Update { |
| 417 |
|
| 418 |
#[arg(long)] |
| 419 |
init: bool, |
| 420 |
paths: Vec<String>, |
| 421 |
}, |
| 422 |
|
| c6aa5bd9 Andy McCall ↶ |
423 |
Status { |
| 424 |
#[arg(long)] |
| 425 |
json: bool, |
| 426 |
}, |
| 4dee277c Andy McCall ↶ |
427 |
|
| 428 |
Remove { path: String }, |
| 429 |
} |
| 430 |
|
| 431 |
#[derive(Subcommand)] |
| 132b884b Andy McCall ↶ |
432 |
enum TagCmd { |
| 433 |
|
| 434 |
Create { |
| 435 |
name: String, |
| 436 |
changes: Vec<String>, |
| 437 |
#[arg(short, long, default_value = "")] |
| 438 |
message: String, |
| 439 |
}, |
| 1196b29b Andy McCall ↶ |
440 |
List { |
| 441 |
#[arg(long)] |
| 442 |
json: bool, |
| 443 |
}, |
| 132b884b Andy McCall ↶ |
444 |
} |
| 445 |
|
| 446 |
#[derive(Subcommand)] |
| fce44ae9 Andy McCall ↶ |
447 |
enum RemoteCmd { |
| 75167672 Andy McCall |
448 |
Add { |
| 449 |
name: String, |
| 450 |
url: String, |
| 451 |
}, |
| 452 |
Remove { |
| 453 |
name: String, |
| 454 |
}, |
| c6aa5bd9 Andy McCall ↶ |
455 |
List { |
| 456 |
#[arg(long)] |
| 457 |
json: bool, |
| 458 |
}, |
| fce44ae9 Andy McCall ↶ |
459 |
} |
| 460 |
|
| 461 |
#[derive(Subcommand)] |
| d82e4409 Andy McCall ↶ |
462 |
enum ProposalCmd { |
| 463 |
|
| 464 |
Show { |
| 465 |
url: String, |
| 466 |
#[arg(long)] |
| 467 |
json: bool, |
| 468 |
}, |
| 469 |
|
| 470 |
Land { |
| 471 |
url: String, |
| 472 |
|
| 473 |
#[arg(long)] |
| 474 |
force: bool, |
| 475 |
}, |
| 476 |
} |
| 477 |
|
| 478 |
#[derive(Subcommand)] |
| fce44ae9 Andy McCall ↶ |
479 |
enum IdentityCmd { |
| 480 |
|
| 481 |
Create { |
| 482 |
#[arg(long)] |
| 483 |
name: Option<String>, |
| 484 |
#[arg(long)] |
| 485 |
email: Option<String>, |
| 486 |
|
| 487 |
#[arg(long)] |
| 488 |
local: bool, |
| 28fc23d7 Andy McCall ↶ |
489 |
|
| 490 |
#[arg(long)] |
| 491 |
expires: Option<u64>, |
| fce44ae9 Andy McCall ↶ |
492 |
}, |
| 493 |
|
| 494 |
Show, |
| 83e0677b Andy McCall ↶ |
495 |
|
| 496 |
Export { path: Option<PathBuf> }, |
| 28fc23d7 Andy McCall ↶ |
497 |
|
| 498 |
Rotate, |
| 499 |
|
| 500 |
Renew { |
| 501 |
#[arg(long)] |
| 502 |
expires: u64, |
| 503 |
}, |
| 504 |
|
| 505 |
Revoke { |
| 506 |
|
| 507 |
key: Option<String>, |
| 508 |
#[arg(long, default_value = "")] |
| 509 |
reason: String, |
| 510 |
}, |
| 511 |
|
| 512 |
Delegate { |
| 513 |
#[command(subcommand)] |
| 514 |
cmd: DelegateCmd, |
| 515 |
}, |
| 516 |
} |
| 517 |
|
| 518 |
#[derive(Subcommand)] |
| 519 |
enum DelegateCmd { |
| 520 |
|
| 521 |
Add { identity_file: PathBuf }, |
| 522 |
|
| 523 |
Remove { key: String }, |
| 524 |
|
| 525 |
List, |
| fce44ae9 Andy McCall ↶ |
526 |
} |
| 527 |
|
| 83e0677b Andy McCall ↶ |
528 |
#[derive(Subcommand)] |
| 79ab8528 Andy McCall ↶ |
529 |
enum GitCmd { |
| 530 |
|
| 30ea9c1e Andy McCall ↶ |
531 |
Export { |
| 532 |
git_dir: PathBuf, |
| 533 |
|
| 534 |
#[arg(long)] |
| 535 |
branch: Option<String>, |
| 536 |
}, |
| 537 |
|
| 538 |
Fetch { |
| 539 |
url: String, |
| 540 |
#[arg(long, default_value = "main")] |
| 541 |
branch: String, |
| 542 |
}, |
| 543 |
|
| 544 |
Push { |
| 545 |
url: String, |
| 546 |
#[arg(long, default_value = "main")] |
| 547 |
branch: String, |
| 548 |
}, |
| c3069537 Andy McCall ↶ |
549 |
|
| 550 |
Import { |
| 551 |
git_dir: PathBuf, |
| 552 |
dest: PathBuf, |
| 553 |
#[arg(long, default_value = "main")] |
| 554 |
branch: String, |
| 555 |
}, |
| 79ab8528 Andy McCall ↶ |
556 |
} |
| 557 |
|
| 558 |
#[derive(Subcommand)] |
| 83e0677b Andy McCall ↶ |
559 |
enum PolicyCmd { |
| 560 |
|
| 561 |
Init, |
| 562 |
|
| c6aa5bd9 Andy McCall ↶ |
563 |
Show { |
| 564 |
#[arg(long)] |
| 565 |
json: bool, |
| 566 |
}, |
| 83e0677b Andy McCall ↶ |
567 |
|
| 568 |
Grant { |
| 569 |
identity_file: PathBuf, |
| 570 |
|
| 571 |
#[arg(long)] |
| 572 |
pattern: Option<String>, |
| 28fc23d7 Andy McCall ↶ |
573 |
|
| 574 |
#[arg(long)] |
| 575 |
out: Option<PathBuf>, |
| 83e0677b Andy McCall ↶ |
576 |
}, |
| 577 |
|
| 28fc23d7 Andy McCall ↶ |
578 |
Revoke { |
| 579 |
key: String, |
| 580 |
|
| 581 |
#[arg(long)] |
| 582 |
out: Option<PathBuf>, |
| 583 |
}, |
| 584 |
|
| 585 |
Root { |
| 586 |
#[command(subcommand)] |
| 587 |
cmd: RootCmd, |
| 588 |
}, |
| 589 |
|
| 590 |
Sign { |
| 591 |
proposal: PathBuf, |
| 592 |
|
| 593 |
#[arg(long)] |
| 594 |
out: Option<PathBuf>, |
| 595 |
}, |
| 596 |
} |
| 597 |
|
| 598 |
#[derive(Subcommand)] |
| 599 |
enum RootCmd { |
| 600 |
|
| 601 |
Add { |
| 602 |
identity_file: PathBuf, |
| 603 |
#[arg(long)] |
| 604 |
out: Option<PathBuf>, |
| 605 |
}, |
| 606 |
|
| 607 |
Remove { |
| 608 |
key: String, |
| 609 |
#[arg(long)] |
| 610 |
out: Option<PathBuf>, |
| 611 |
}, |
| 612 |
|
| 613 |
Threshold { |
| 614 |
n: u32, |
| 615 |
#[arg(long)] |
| 616 |
out: Option<PathBuf>, |
| 617 |
}, |
| 83e0677b Andy McCall ↶ |
618 |
} |
| 619 |
|
| fce44ae9 Andy McCall ↶ |
620 |
|
| 621 |
fn open() -> Result<Repo> { |
| 622 |
Repo::open(&std::env::current_dir()?).context("opening repository") |
| 623 |
} |
| 624 |
|
| 625 |
|
| 626 |
pub fn run() -> Result<i32> { |
| 627 |
let cli = Cli::parse(); |
| 135212de Andy McCall ↶ |
628 |
ui::init(cli.plain); |
| fce44ae9 Andy McCall ↶ |
629 |
match cli.cmd { |
| e02bf0cd Andy McCall ↶ |
630 |
Cmd::Init { path, bare } => workspace::init(path, bare), |
| 50a046e4 Andy McCall ↶ |
631 |
Cmd::Status { json } => workspace::status(json), |
| 75167672 Andy McCall |
632 |
Cmd::Prompt { |
| 633 |
format, |
| 634 |
glyphs, |
| 635 |
color, |
| 636 |
} => workspace::prompt(&format, glyphs, color.as_deref()), |
| 637 |
Cmd::Commit { |
| 638 |
message, |
| 639 |
depends_on, |
| 640 |
paths, |
| 641 |
interactive, |
| 642 |
hunks, |
| 643 |
} => workspace::commit(&message, &depends_on, &paths, interactive, &hunks), |
| c6aa5bd9 Andy McCall ↶ |
644 |
Cmd::Cat { path, change } => workspace::cat(&path, change.as_deref()), |
| 645 |
Cmd::Root { json } => workspace::root(json), |
| 646 |
Cmd::Version { json } => workspace::version(json), |
| 647 |
Cmd::Discard { paths, hunks } => workspace::discard(&paths, &hunks), |
| 648 |
Cmd::Hunks { json } => workspace::hunks(json), |
| 728da0f9 Andy McCall ↶ |
649 |
Cmd::Squash { change, into } => workspace::squash(&change, &into), |
| 650 |
Cmd::Rebase { change, onto } => workspace::rebase(&change, &onto), |
| 957fee30 Andy McCall ↶ |
651 |
Cmd::Blame { path, json } => workspace::blame(&path, json), |
| 652 |
Cmd::Bisect { cmd } => match cmd { |
| 653 |
BisectCmd::Start => workspace::bisect_start(), |
| 654 |
BisectCmd::Good { changes } => workspace::bisect_mark(Some(true), &changes), |
| 655 |
BisectCmd::Bad { changes } => workspace::bisect_mark(Some(false), &changes), |
| 656 |
BisectCmd::Skip => workspace::bisect_mark(None, &[]), |
| 657 |
BisectCmd::Run { command } => workspace::bisect_run(&command), |
| c6aa5bd9 Andy McCall ↶ |
658 |
BisectCmd::Status { json } => workspace::bisect_status(json), |
| 957fee30 Andy McCall ↶ |
659 |
BisectCmd::Reset => workspace::bisect_reset(), |
| 660 |
}, |
| 75167672 Andy McCall |
661 |
Cmd::Log { |
| 662 |
limit, |
| 663 |
verbose, |
| 664 |
path, |
| 665 |
json, |
| 666 |
} => workspace::log(limit, verbose, path.as_deref(), json), |
| c6aa5bd9 Andy McCall ↶ |
667 |
Cmd::Diff { change, json } => workspace::diff(change.as_deref(), json), |
| 614541c3 Andy McCall ↶ |
668 |
Cmd::Describe { message, change } => workspace::describe(&message, change.as_deref()), |
| 23b217d7 Andy McCall ↶ |
669 |
Cmd::Amend { message, into } => workspace::amend(message.as_deref(), into.as_deref()), |
| 670 |
Cmd::Split { change, paths } => workspace::split(&change, &paths), |
| 614541c3 Andy McCall ↶ |
671 |
Cmd::Abandon { change } => workspace::abandon(&change), |
| c6aa5bd9 Andy McCall ↶ |
672 |
Cmd::Show { change, json } => workspace::show(&change, json), |
| fce44ae9 Andy McCall ↶ |
673 |
Cmd::Checkout { changes, discard } => workspace::checkout(&changes, discard), |
| c6aa5bd9 Andy McCall ↶ |
674 |
Cmd::Resolve { json } => workspace::resolve(json), |
| fce44ae9 Andy McCall ↶ |
675 |
Cmd::Undo => workspace::undo(), |
| ba160f60 Andy McCall ↶ |
676 |
Cmd::Gc { now } => workspace::gc(now), |
| 252e8cb2 Andy McCall ↶ |
677 |
Cmd::Checkpoint => workspace::checkpoint(), |
| 75167672 Andy McCall |
678 |
Cmd::Op { |
| 679 |
cmd: OpCmd::Log { json }, |
| 680 |
} => workspace::op_log(json), |
| 681 |
Cmd::Clone { |
| 682 |
url, |
| 683 |
dest, |
| 684 |
max_blob, |
| 685 |
sparse, |
| 686 |
depth, |
| 687 |
} => sync::clone(&url, dest, max_blob.as_deref(), &sparse, depth), |
| 2863456a Andy McCall ↶ |
688 |
Cmd::Deepen { depth, remote } => sync::deepen(&remote, depth), |
| 7421309f Andy McCall ↶ |
689 |
Cmd::Sparse { paths } => workspace::sparse(&paths), |
| cdb5beba Andy McCall ↶ |
690 |
Cmd::Lock { path } => workspace::lock(&path), |
| 691 |
Cmd::Unlock { path } => workspace::unlock(&path), |
| 4e88e774 Andy McCall ↶ |
692 |
Cmd::Workspace { cmd } => match cmd { |
| 693 |
WorkspaceCmd::Add { path, changes } => workspace::workspace_add(&path, &changes), |
| 1196b29b Andy McCall ↶ |
694 |
WorkspaceCmd::List { json } => workspace::workspace_list(json), |
| 4e88e774 Andy McCall ↶ |
695 |
WorkspaceCmd::Forget { workspace } => workspace::workspace_forget(&workspace), |
| 696 |
}, |
| 7b9809e6 Andy McCall ↶ |
697 |
Cmd::Bookmark { cmd } => match cmd { |
| 698 |
BookmarkCmd::Create { name, changes } => workspace::bookmark_create(&name, &changes), |
| 699 |
BookmarkCmd::Set { name, changes } => workspace::bookmark_set(&name, &changes), |
| 700 |
BookmarkCmd::Delete { name } => workspace::bookmark_delete(&name), |
| c6aa5bd9 Andy McCall ↶ |
701 |
BookmarkCmd::List { json } => workspace::bookmark_list(json), |
| 7b9809e6 Andy McCall ↶ |
702 |
BookmarkCmd::Switch { name, discard } => workspace::bookmark_switch(&name, discard), |
| 703 |
}, |
| 704 |
Cmd::Merge { bookmark } => workspace::merge(&bookmark), |
| 4dee277c Andy McCall ↶ |
705 |
Cmd::Submodule { cmd } => match cmd { |
| 75167672 Andy McCall |
706 |
SubmoduleCmd::Add { |
| 707 |
url, |
| 708 |
path, |
| 709 |
bookmark, |
| 710 |
} => sync::submodule_add(&url, &path, bookmark.as_deref()), |
| 4dee277c Andy McCall ↶ |
711 |
SubmoduleCmd::Update { init, paths } => sync::submodule_update(init, &paths), |
| c6aa5bd9 Andy McCall ↶ |
712 |
SubmoduleCmd::Status { json } => sync::submodule_status(json), |
| 4dee277c Andy McCall ↶ |
713 |
SubmoduleCmd::Remove { path } => sync::submodule_remove(&path), |
| 714 |
}, |
| 132b884b Andy McCall ↶ |
715 |
Cmd::Tag { cmd } => match cmd { |
| 75167672 Andy McCall |
716 |
TagCmd::Create { |
| 717 |
name, |
| 718 |
changes, |
| 719 |
message, |
| 720 |
} => workspace::tag_create(&name, &changes, &message), |
| 1196b29b Andy McCall ↶ |
721 |
TagCmd::List { json } => workspace::tag_list(json), |
| 132b884b Andy McCall ↶ |
722 |
}, |
| fce44ae9 Andy McCall ↶ |
723 |
Cmd::Remote { cmd } => match cmd { |
| 724 |
RemoteCmd::Add { name, url } => sync::remote_add(&name, &url), |
| 725 |
RemoteCmd::Remove { name } => sync::remote_remove(&name), |
| c6aa5bd9 Andy McCall ↶ |
726 |
RemoteCmd::List { json } => sync::remote_list(json), |
| fce44ae9 Andy McCall ↶ |
727 |
}, |
| c6aa5bd9 Andy McCall ↶ |
728 |
Cmd::Fetch { remote, json } => sync::fetch(remote.as_deref(), json), |
| 729 |
Cmd::Pull { remote, json } => sync::pull(remote.as_deref(), json), |
| 75167672 Andy McCall |
730 |
Cmd::Push { |
| 731 |
remote, |
| 732 |
force, |
| 733 |
bookmark, |
| 734 |
json, |
| 735 |
} => sync::push(remote.as_deref(), force, bookmark.as_deref(), json), |
| 736 |
Cmd::Serve { |
| 737 |
root, |
| 738 |
bind, |
| 739 |
tokens, |
| 740 |
tls_cert, |
| 741 |
tls_key, |
| 742 |
} => sync::serve(root, &bind, tokens, tls_cert.zip(tls_key)), |
| fce44ae9 Andy McCall ↶ |
743 |
Cmd::Identity { cmd } => match cmd { |
| 75167672 Andy McCall |
744 |
IdentityCmd::Create { |
| 745 |
name, |
| 746 |
email, |
| 747 |
local, |
| 748 |
expires, |
| 749 |
} => identity::create(name, email, local, expires), |
| fce44ae9 Andy McCall ↶ |
750 |
IdentityCmd::Show => identity::show(), |
| 83e0677b Andy McCall ↶ |
751 |
IdentityCmd::Export { path } => identity::export(path), |
| 28fc23d7 Andy McCall ↶ |
752 |
IdentityCmd::Rotate => identity::rotate(), |
| 753 |
IdentityCmd::Renew { expires } => identity::renew(expires), |
| 754 |
IdentityCmd::Revoke { key, reason } => identity::revoke(key.as_deref(), &reason), |
| 755 |
IdentityCmd::Delegate { cmd } => match cmd { |
| 756 |
DelegateCmd::Add { identity_file } => identity::delegate_add(&identity_file), |
| 757 |
DelegateCmd::Remove { key } => identity::delegate_remove(&key), |
| 758 |
DelegateCmd::List => identity::delegate_list(), |
| 759 |
}, |
| 83e0677b Andy McCall ↶ |
760 |
}, |
| 75167672 Andy McCall |
761 |
Cmd::Git { |
| 762 |
cmd: GitCmd::Export { git_dir, branch }, |
| 763 |
} => sync::git_export(&git_dir, branch.as_deref()), |
| 764 |
Cmd::Git { |
| 765 |
cmd: GitCmd::Fetch { url, branch }, |
| 766 |
} => sync::git_fetch(&url, &branch), |
| 767 |
Cmd::Git { |
| 768 |
cmd: GitCmd::Push { url, branch }, |
| 769 |
} => sync::git_push(&url, &branch), |
| 770 |
Cmd::Git { |
| 771 |
cmd: |
| 772 |
GitCmd::Import { |
| 773 |
git_dir, |
| 774 |
dest, |
| 775 |
branch, |
| 776 |
}, |
| 777 |
} => sync::git_import(&git_dir, &dest, &branch), |
| 83e0677b Andy McCall ↶ |
778 |
Cmd::Policy { cmd } => match cmd { |
| 779 |
PolicyCmd::Init => identity::policy_init(), |
| c6aa5bd9 Andy McCall ↶ |
780 |
PolicyCmd::Show { json } => identity::policy_show(json), |
| 75167672 Andy McCall |
781 |
PolicyCmd::Grant { |
| 782 |
identity_file, |
| 783 |
pattern, |
| 784 |
out, |
| 785 |
} => identity::policy_grant(&identity_file, pattern.as_deref(), out), |
| 28fc23d7 Andy McCall ↶ |
786 |
PolicyCmd::Revoke { key, out } => identity::policy_revoke(&key, out), |
| 787 |
PolicyCmd::Root { cmd } => match cmd { |
| 75167672 Andy McCall |
788 |
RootCmd::Add { identity_file, out } => { |
| 789 |
identity::policy_root_add(&identity_file, out) |
| 790 |
} |
| 28fc23d7 Andy McCall ↶ |
791 |
RootCmd::Remove { key, out } => identity::policy_root_remove(&key, out), |
| 792 |
RootCmd::Threshold { n, out } => identity::policy_threshold(n, out), |
| 793 |
}, |
| 794 |
PolicyCmd::Sign { proposal, out } => identity::policy_sign(&proposal, out), |
| fce44ae9 Andy McCall ↶ |
795 |
}, |
| d82e4409 Andy McCall ↶ |
796 |
Cmd::Seal { changes, proposal: Some(url), json } if changes.is_empty() => proposal::seal(&url, json), |
| 797 |
Cmd::Seal { changes, json, .. } => identity::seal(&changes, json), |
| 798 |
Cmd::Proposal { cmd } => match cmd { |
| 799 |
ProposalCmd::Show { url, json } => proposal::show(&url, json), |
| 800 |
ProposalCmd::Land { url, force } => proposal::land(&url, force), |
| 801 |
}, |
| c6aa5bd9 Andy McCall ↶ |
802 |
Cmd::Verify { change, json } => identity::verify(change.as_deref(), json), |
| fce44ae9 Andy McCall ↶ |
803 |
Cmd::Config { key, value, user } => identity::config(&key, &value, user), |
| 804 |
} |
| 805 |
} |