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