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