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