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