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