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