OXYGENHUB
# d6e0d5b8b339 oxygen / src / cli / mod.rs
51.5 KiB · Rust · last changed git import and fetch --claim: author your own commits with your key 25 days ago source blame history raw
fce44ae9 Andy McCall ↶ 1
//! Command-line definitions and dispatch.
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",
e293c90d Andy McCall ↶ 21
    version = env!("OXY_VERSION_LONG"),
75167672 Andy McCall 22
    about = "Oxygen: breathing fresh air into version control"
23
)]
fce44ae9 Andy McCall ↶ 24
struct Cli {
135212de Andy McCall ↶ 25
    /// Plain output: no colour, no spinner (also implied by NO_COLOR or a non-terminal)
26
    #[arg(long, global = true)]
27
    plain: bool,
98a1620a Andy McCall ↶ 28
    /// Read the repository as it was after operation OP (an ID from oxy op log, @ or @-); commands that would change it are refused
29
    #[arg(long, global = true, value_name = "OP")]
30
    at_op: Option<String>,
fce44ae9 Andy McCall ↶ 31
    #[command(subcommand)]
32
    cmd: Cmd,
33
}
34
98a1620a Andy McCall ↶ 35
/// `--at-op`, for `open` to apply.
36
static AT_OP: std::sync::OnceLock<Option<String>> = std::sync::OnceLock::new();
37
fce44ae9 Andy McCall ↶ 38
#[derive(Subcommand)]
39
enum Cmd {
40
    /// Create a repository in PATH (default: current directory)
e02bf0cd Andy McCall ↶ 41
    Init {
d42369ab Andy McCall 42
        /// Directory to create the repository in (default: the current directory)
e02bf0cd Andy McCall ↶ 43
        path: Option<PathBuf>,
44
        /// No working copy: an object store and references only, for hosting
45
        #[arg(long)]
46
        bare: bool,
d069701a Andy McCall ↶ 47
        /// Keep the objects and the operation log on this store
48
        /// (dir://PATH, s3://BUCKET/PREFIX, gs://…, az://…) instead of
49
        /// in .oxy, with a local cache in front (storage.cache, 2 GiB)
50
        #[arg(long, value_name = "URL")]
51
        store: Option<String>,
e02bf0cd Andy McCall ↶ 52
    },
fce44ae9 Andy McCall ↶ 53
    /// Clone a repository from a local path or an http(s) URL
b3c5a59a Andy McCall ↶ 54
    Clone {
d42369ab Andy McCall 55
        /// Local path or http(s) URL of the repository
b3c5a59a Andy McCall ↶ 56
        url: String,
d42369ab Andy McCall 57
        /// Directory to clone into (default: the last part of the URL)
b3c5a59a Andy McCall ↶ 58
        dest: Option<PathBuf>,
59
        /// Leave blobs larger than this (e.g. 1M) to be fetched on first read
60
        #[arg(long)]
61
        max_blob: Option<String>,
7421309f Andy McCall ↶ 62
        /// Materialize only these paths (repeatable); implies lazy blobs
63
        #[arg(long = "sparse")]
64
        sparse: Vec<String>,
2863456a Andy McCall ↶ 65
        /// Shallow clone: fetch only this many levels of history below the heads
66
        #[arg(long)]
67
        depth: Option<u32>,
14edbaaf Andy McCall ↶ 68
        /// Clone the subrepos too (as oxy submodule update --init)
69
        #[arg(long)]
70
        recursive: bool,
b3c5a59a Andy McCall ↶ 71
    },
2863456a Andy McCall ↶ 72
    /// Fetch more history below a shallow clone's boundary
73
    Deepen {
d42369ab Andy McCall 74
        /// Levels of history to add below the boundary
2863456a Andy McCall ↶ 75
        #[arg(default_value_t = 10)]
76
        depth: u32,
d42369ab Andy McCall 77
        /// Remote to fetch the history from
2863456a Andy McCall ↶ 78
        #[arg(long, default_value = "origin")]
79
        remote: String,
80
    },
7421309f Andy McCall ↶ 81
    /// Show or set the sparse filter (paths to materialize); re-checks out the bookmark
d42369ab Andy McCall 82
    Sparse {
83
        /// Paths to materialize; none prints the current filter
84
        paths: Vec<String>,
85
    },
fce44ae9 Andy McCall ↶ 86
    /// Show the working copy: changed paths and conflicts
50a046e4 Andy McCall ↶ 87
    Status {
88
        /// Machine-readable output: paths, and every conflict with its kind and contributing changes
89
        #[arg(long)]
90
        json: bool,
91
    },
135212de Andy McCall ↶ 92
    /// One-line summary for shell prompts; fast and records nothing
93
    Prompt {
694805cc Andy McCall ↶ 94
        /// Placeholders: %b bookmark, %c change id, %h heads, %d dirty (*), %x conflict (!), %A/%D ahead/behind (+n/-n), %a/%B raw counts, %s state glyph, %U/%O ahead/behind arrows, %i icon
135212de Andy McCall ↶ 95
        #[arg(long, default_value = oxy_core::repo::DEFAULT_PROMPT_FORMAT)]
96
        format: String,
694805cc Andy McCall ↶ 97
        /// Glyph format (%i %b %c %s%U%O) instead of the plain default
98
        #[arg(long)]
99
        glyphs: bool,
100
        /// Colour by state (cyan clean, yellow dirty, red conflicted): raw escapes, or guarded for a bash or zsh PS1
101
        #[arg(long, value_parser = ["raw", "bash", "zsh"])]
102
        color: Option<String>,
135212de Andy McCall ↶ 103
    },
fce44ae9 Andy McCall ↶ 104
    /// Record the working copy as a change on the current bookmark
105
    Commit {
d42369ab Andy McCall 106
        /// The change's message: a subject line, then optionally a blank line and a body
6a81dbab Andy McCall ↶ 107
        #[arg(short, long, required_unless_present = "file", conflicts_with = "file")]
108
        message: Option<String>,
109
        /// Read the message from FILE (`-` for standard input)
110
        #[arg(short = 'F', long, value_name = "FILE")]
111
        file: Option<PathBuf>,
fce44ae9 Andy McCall ↶ 112
        /// Extra explicit dependencies (ChangeId prefix, #hash prefix)
113
        #[arg(long = "depends-on")]
114
        depends_on: Vec<String>,
957fee30 Andy McCall ↶ 115
        /// Commit only these paths; the rest stays as uncommitted work
116
        paths: Vec<String>,
117
        /// Choose hunks one by one
118
        #[arg(short, long)]
119
        interactive: bool,
c6aa5bd9 Andy McCall ↶ 120
        /// Commit these hunks (as `oxy hunks` numbers them), comma separated
121
        #[arg(long, value_delimiter = ',')]
122
        hunks: Vec<usize>,
fce44ae9 Andy McCall ↶ 123
    },
728da0f9 Andy McCall ↶ 124
    /// Fold CHANGE into one of its dependencies (keeps that change's id)
125
    Squash {
d42369ab Andy McCall 126
        /// The change to fold (ChangeId prefix, #hash prefix)
728da0f9 Andy McCall ↶ 127
        change: String,
d42369ab Andy McCall 128
        /// The dependency that absorbs it
728da0f9 Andy McCall ↶ 129
        #[arg(long)]
130
        into: String,
131
    },
132
    /// Re-express CHANGE against another base state
133
    Rebase {
d42369ab Andy McCall 134
        /// The change to re-express (ChangeId prefix, #hash prefix)
728da0f9 Andy McCall ↶ 135
        change: String,
136
        /// The changes, bookmark or tag whose state becomes the new base
137
        #[arg(long, required = true, num_args = 1..)]
138
        onto: Vec<String>,
e266b7d4 Andy McCall ↶ 139
        /// Where the rebase would be conflicted, merge the target into the
140
        /// current bookmark instead, leaving the conflict in the working
141
        /// copy to fix and commit
142
        #[arg(long)]
143
        into_working_copy: bool,
728da0f9 Andy McCall ↶ 144
    },
957fee30 Andy McCall ↶ 145
    /// Show which change introduced each line of a file
146
    Blame {
d42369ab Andy McCall 147
        /// File to annotate, relative to the repository root
957fee30 Andy McCall ↶ 148
        path: String,
d42369ab Andy McCall 149
        /// Machine-readable output: one JSON document on stdout
957fee30 Andy McCall ↶ 150
        #[arg(long)]
151
        json: bool,
152
    },
153
    /// Find the change that introduced a regression
154
    Bisect {
155
        #[command(subcommand)]
156
        cmd: BisectCmd,
157
    },
fce44ae9 Andy McCall ↶ 158
    /// List changes reachable from the bookmark and the working copy
94084087 Andy McCall ↶ 159
    Log {
bf3a6781 Andy McCall ↶ 160
        /// Show the changes a revset selects: `main` (a bookmark name means its
161
        /// heads; `bookmark(main)` only ever the bookmark), `main..feature &
162
        /// author(andy)`, `touches("src/**") & date(-7d..)` (see
163
        /// docs/revset_query_language.md)
47ce8b8e Andy McCall ↶ 164
        #[arg(short = 'r', long, value_name = "REVSET", conflicts_with_all = ["path", "lines"])]
165
        revset: Option<String>,
94084087 Andy McCall ↶ 166
        /// Show at most this many changes
167
        #[arg(short = 'n', long)]
168
        limit: Option<usize>,
169
        /// Show full messages, dependencies, and signatures
170
        #[arg(short, long)]
171
        verbose: bool,
c6aa5bd9 Andy McCall ↶ 172
        /// Only changes touching this path (renames followed)
173
        #[arg(long)]
174
        path: Option<String>,
83d61e80 Andy McCall ↶ 175
        /// Only changes that wrote or deleted lines START to END of PATH
176
        /// (numbered as in the working copy's base), or deleted lines from
177
        /// between them: the history of a function
178
        #[arg(short = 'L', value_name = "START,END:PATH", conflicts_with = "path")]
179
        lines: Option<String>,
d42369ab Andy McCall 180
        /// Machine-readable output: one JSON document on stdout
c6aa5bd9 Andy McCall ↶ 181
        #[arg(long)]
182
        json: bool,
94084087 Andy McCall ↶ 183
    },
fce44ae9 Andy McCall ↶ 184
    /// Show what the working copy changes against its base
c6aa5bd9 Andy McCall ↶ 185
    Diff {
186
        /// A change instead of the working copy
187
        change: Option<String>,
d42369ab Andy McCall 188
        /// Machine-readable output: one JSON document on stdout
c6aa5bd9 Andy McCall ↶ 189
        #[arg(long)]
190
        json: bool,
191
    },
192
    /// Print a file as it is in a state (default: the working copy's base)
193
    Cat {
d42369ab Andy McCall 194
        /// File to print, relative to the repository root
c6aa5bd9 Andy McCall ↶ 195
        path: String,
196
        /// A change, bookmark, or tag
197
        #[arg(short = 'r', long)]
198
        change: Option<String>,
199
    },
200
    /// Print the repository root, workspace, and bookmark
201
    Root {
d42369ab Andy McCall 202
        /// Machine-readable output: one JSON document on stdout
c6aa5bd9 Andy McCall ↶ 203
        #[arg(long)]
204
        json: bool,
205
    },
206
    /// Print the version of oxy, its repository format, and protocol
207
    Version {
d42369ab Andy McCall 208
        /// Machine-readable output: one JSON document on stdout
c6aa5bd9 Andy McCall ↶ 209
        #[arg(long)]
210
        json: bool,
211
    },
212
    /// Restore paths to the working copy's base, or undo chosen hunks
213
    Discard {
d42369ab Andy McCall 214
        /// Paths to restore; none with --hunks, or everything with neither
c6aa5bd9 Andy McCall ↶ 215
        paths: Vec<String>,
216
        /// Hunk indices as `oxy hunks` numbers them, comma separated
217
        #[arg(long, value_delimiter = ',')]
218
        hunks: Vec<usize>,
219
    },
220
    /// List the working copy's hunks, numbered as commit --hunks expects
221
    Hunks {
d42369ab Andy McCall 222
        /// Machine-readable output: one JSON document on stdout
c6aa5bd9 Andy McCall ↶ 223
        #[arg(long)]
224
        json: bool,
225
    },
6a81dbab Andy McCall ↶ 226
    /// With -m, change the message of a head; without, name the working
227
    /// copy for a build: its tag, or the nearest tag plus distance and
228
    /// change, or the bookmark and change, and -dirty
614541c3 Andy McCall ↶ 229
    Describe {
d42369ab Andy McCall 230
        /// The new message
614541c3 Andy McCall ↶ 231
        #[arg(short, long)]
6a81dbab Andy McCall ↶ 232
        message: Option<String>,
d42369ab Andy McCall 233
        /// The head to describe (default: the one the working copy sits on)
614541c3 Andy McCall ↶ 234
        change: Option<String>,
6a81dbab Andy McCall ↶ 235
        /// Machine-readable output (naming only)
236
        #[arg(long, conflicts_with = "message")]
237
        json: bool,
614541c3 Andy McCall ↶ 238
    },
23b217d7 Andy McCall ↶ 239
    /// Fold the working copy into the head it sits on, or into CHANGE with --into
614541c3 Andy McCall ↶ 240
    Amend {
d42369ab Andy McCall 241
        /// Replace the message too
614541c3 Andy McCall ↶ 242
        #[arg(short, long)]
243
        message: Option<String>,
23b217d7 Andy McCall ↶ 244
        /// Amend an older change; the edits must touch only lines it already knows
245
        #[arg(long)]
246
        into: Option<String>,
614541c3 Andy McCall ↶ 247
    },
23b217d7 Andy McCall ↶ 248
    /// Split a head: the named paths become a separate first change
d42369ab Andy McCall 249
    Split {
250
        /// The head to split
251
        change: String,
252
        /// Paths whose edits become the first change
253
        paths: Vec<String>,
254
    },
2c9ddac3 Andy McCall ↶ 255
    /// Drop a change from the bookmark; its content stays on disk as uncommitted work
d42369ab Andy McCall 256
    Abandon {
2c9ddac3 Andy McCall ↶ 257
        /// The change to drop (ChangeId prefix, #hash prefix)
258
        #[arg(required_unless_present = "revset")]
259
        change: Option<String>,
260
        /// Drop every change a revset selects, newest first
261
        #[arg(short = 'r', long, value_name = "REVSET", conflicts_with = "change")]
262
        revset: Option<String>,
263
        /// Drop more than five changes without asking
264
        #[arg(long, short = 'y')]
265
        yes: bool,
d42369ab Andy McCall 266
    },
2c9ddac3 Andy McCall ↶ 267
    /// Show one change (ChangeId prefix, #hash prefix, or @), or those a revset selects
c6aa5bd9 Andy McCall ↶ 268
    Show {
d42369ab Andy McCall 269
        /// ChangeId prefix, #hash prefix, or @ for the working copy
2c9ddac3 Andy McCall ↶ 270
        #[arg(required_unless_present = "revset")]
271
        change: Option<String>,
272
        /// Show every change a revset selects
273
        #[arg(short = 'r', long, value_name = "REVSET", conflicts_with = "change")]
274
        revset: Option<String>,
d42369ab Andy McCall 275
        /// Machine-readable output: one JSON document on stdout
c6aa5bd9 Andy McCall ↶ 276
        #[arg(long)]
277
        json: bool,
278
    },
fce44ae9 Andy McCall ↶ 279
    /// Move the working copy to the state formed by CHANGE... (default: the bookmark heads)
280
    Checkout {
d42369ab Andy McCall 281
        /// Changes whose state to check out (default: the bookmark heads)
fce44ae9 Andy McCall ↶ 282
        changes: Vec<String>,
283
        /// Throw away uncommitted working-copy changes
284
        #[arg(long)]
285
        discard: bool,
1c2bd9ab Andy McCall ↶ 286
        /// Take uncommitted changes along; refused when the target has
287
        /// other versions of the files they touch
288
        #[arg(long, conflicts_with = "discard")]
289
        carry: bool,
fce44ae9 Andy McCall ↶ 290
    },
291
    /// Report which conflicts of the working copy's base are resolved by the current files
c6aa5bd9 Andy McCall ↶ 292
    Resolve {
d42369ab Andy McCall 293
        /// Machine-readable output: one JSON document on stdout
c6aa5bd9 Andy McCall ↶ 294
        #[arg(long)]
295
        json: bool,
296
    },
fce44ae9 Andy McCall ↶ 297
    /// Undo the last operation
298
    Undo,
252e8cb2 Andy McCall ↶ 299
    /// Write a checkpoint of the current bookmark's state now
300
    Checkpoint,
d42369ab Andy McCall 301
    /// Print a shell completion script: `oxy completions bash > ~/.local/share/bash-completion/completions/oxy`
302
    Completions {
303
        /// bash, zsh, fish, elvish or powershell
304
        shell: clap_complete::Shell,
305
    },
306
    /// Write man pages (oxy.1 and one per command) into DIR, or print oxy.1
307
    Man {
308
        /// Directory to write every page into, e.g. ~/.local/share/man/man1
309
        #[arg(long)]
310
        dir: Option<PathBuf>,
311
    },
3e5772cc Andy McCall ↶ 312
    /// Check the identity, configuration and remotes, and say what to do about any problem
313
    Doctor {
314
        /// Do not contact the remotes
315
        #[arg(long)]
316
        offline: bool,
d42369ab Andy McCall 317
        /// Machine-readable output: one JSON document on stdout
3e5772cc Andy McCall ↶ 318
        #[arg(long)]
319
        json: bool,
320
    },
387335ff Andy McCall ↶ 321
    /// Check the repository's integrity: objects, operation log, references, signatures, checkpoints
322
    Fsck {
d42369ab Andy McCall 323
        /// Machine-readable output: one JSON document on stdout
387335ff Andy McCall ↶ 324
        #[arg(long)]
325
        json: bool,
326
    },
da652d63 Andy McCall ↶ 327
    /// Prune unreachable objects older than the grace period and repack everything into one pack
ba160f60 Andy McCall ↶ 328
    Gc {
329
        /// Ignore the grace period (core.gc-grace) and prune immediately
330
        #[arg(long)]
331
        now: bool,
332
    },
fce44ae9 Andy McCall ↶ 333
    /// List operations
334
    #[command(name = "op")]
335
    Op {
336
        #[command(subcommand)]
337
        cmd: OpCmd,
338
    },
cdb5beba Andy McCall ↶ 339
    /// Take the advisory local lock on a lockable file, making it writable
d42369ab Andy McCall 340
    Lock {
341
        /// The lockable file
342
        path: String,
343
    },
cdb5beba Andy McCall ↶ 344
    /// Release the local lock and make the file read-only again
d42369ab Andy McCall 345
    Unlock {
346
        /// The locked file
347
        path: String,
348
    },
4e88e774 Andy McCall ↶ 349
    /// Workspaces: extra checkout directories sharing this repository
350
    Workspace {
351
        #[command(subcommand)]
352
        cmd: WorkspaceCmd,
353
    },
7b9809e6 Andy McCall ↶ 354
    /// Bookmarks: named states; each workspace works on one
355
    Bookmark {
356
        #[command(subcommand)]
357
        cmd: BookmarkCmd,
358
    },
359
    /// Union another bookmark's heads into the current one (no merge change)
d42369ab Andy McCall 360
    Merge {
361
        /// The bookmark whose heads to add
362
        bookmark: String,
363
    },
ff1f62fe Andy McCall ↶ 364
    /// Sign in to a hub once, for every repository on it
365
    Auth {
366
        #[command(subcommand)]
367
        cmd: AuthCmd,
368
    },
4dee277c Andy McCall ↶ 369
    /// Subrepositories: nested repositories pinned to a state
370
    Submodule {
371
        #[command(subcommand)]
372
        cmd: SubmoduleCmd,
373
    },
fc1a466a Andy McCall ↶ 374
    /// Execution receipts: signed records of what a runner ran on a state
375
    Receipt {
376
        #[command(subcommand)]
377
        cmd: ReceiptCmd,
378
    },
132b884b Andy McCall ↶ 379
    /// Tags: immutable named states
380
    Tag {
381
        #[command(subcommand)]
382
        cmd: TagCmd,
383
    },
fce44ae9 Andy McCall ↶ 384
    /// Manage remotes
385
    Remote {
386
        #[command(subcommand)]
387
        cmd: RemoteCmd,
388
    },
389
    /// Fetch every bookmark of a remote into its tracking references
c6aa5bd9 Andy McCall ↶ 390
    Fetch {
d42369ab Andy McCall 391
        /// Remote name (default: origin)
c6aa5bd9 Andy McCall ↶ 392
        remote: Option<String>,
d42369ab Andy McCall 393
        /// Machine-readable output: one JSON document on stdout
c6aa5bd9 Andy McCall ↶ 394
        #[arg(long)]
395
        json: bool,
396
    },
fce44ae9 Andy McCall ↶ 397
    /// Fetch, then union the remote bookmark into the local one (no merge change)
c6aa5bd9 Andy McCall ↶ 398
    Pull {
d42369ab Andy McCall 399
        /// Remote name (default: origin)
c6aa5bd9 Andy McCall ↶ 400
        remote: Option<String>,
d42369ab Andy McCall 401
        /// Machine-readable output: one JSON document on stdout
c6aa5bd9 Andy McCall ↶ 402
        #[arg(long)]
403
        json: bool,
404
    },
fce44ae9 Andy McCall ↶ 405
    /// Push the current bookmark to a remote
406
    Push {
d42369ab Andy McCall 407
        /// Remote name (default: origin)
fce44ae9 Andy McCall ↶ 408
        remote: Option<String>,
409
        /// Allow dropping heads the remote has
410
        #[arg(long)]
411
        force: bool,
7b9809e6 Andy McCall ↶ 412
        /// Push this bookmark instead of the workspace's current one
413
        #[arg(short = 'b', long)]
414
        bookmark: Option<String>,
f8c69576 Andy McCall ↶ 415
        /// Delete this bookmark on the remote (never its default bookmark);
416
        /// the local bookmark is kept
417
        #[arg(long, value_name = "NAME", conflicts_with_all = ["bookmark", "force"])]
418
        delete: Option<String>,
d42369ab Andy McCall 419
        /// Machine-readable output: one JSON document on stdout
c6aa5bd9 Andy McCall ↶ 420
        #[arg(long)]
421
        json: bool,
fce44ae9 Andy McCall ↶ 422
    },
2b5ee371 Andy McCall ↶ 423
    /// Serve repositories under ROOT over HTTPS (with --tls-cert/--tls-key) or plain HTTP
fce44ae9 Andy McCall ↶ 424
    Serve {
425
        /// Directory with one repository per subdirectory
426
        #[arg(long, default_value = ".")]
427
        root: PathBuf,
d42369ab Andy McCall 428
        /// Address and port to listen on
fce44ae9 Andy McCall ↶ 429
        #[arg(long, default_value = "127.0.0.1:8890")]
430
        bind: String,
431
        /// Bearer token allowed to push (repeatable); none means open
432
        #[arg(long = "token")]
433
        tokens: Vec<String>,
2b5ee371 Andy McCall ↶ 434
        /// PEM certificate chain; enables HTTPS together with --tls-key
435
        #[arg(long, requires = "tls_key")]
436
        tls_cert: Option<PathBuf>,
437
        /// PEM private key
438
        #[arg(long, requires = "tls_cert")]
439
        tls_key: Option<PathBuf>,
fce44ae9 Andy McCall ↶ 440
    },
441
    /// Manage the signing identity
442
    Identity {
443
        #[command(subcommand)]
444
        cmd: IdentityCmd,
445
    },
05e71ed6 Andy McCall ↶ 446
    /// Seal changes with your key: named ones, or every change on the current bookmark you can authenticate but have not
447
    Seal {
d42369ab Andy McCall 448
        /// Changes to seal (default: every change on the bookmark you can authenticate and have not sealed)
05e71ed6 Andy McCall ↶ 449
        changes: Vec<String>,
d82e4409 Andy McCall ↶ 450
        /// Seal every change of a hub proposal and push the seal (your approval)
451
        #[arg(long, conflicts_with = "changes")]
452
        proposal: Option<String>,
d42369ab Andy McCall 453
        /// Machine-readable output: one JSON document on stdout
05e71ed6 Andy McCall ↶ 454
        #[arg(long)]
455
        json: bool,
456
    },
d82e4409 Andy McCall ↶ 457
    /// Hub proposals: show one, or land it from this client
458
    Proposal {
459
        #[command(subcommand)]
460
        cmd: ProposalCmd,
461
    },
fce44ae9 Andy McCall ↶ 462
    /// Verify the signatures on a change (default: every change in the log)
c6aa5bd9 Andy McCall ↶ 463
    Verify {
d42369ab Andy McCall 464
        /// The change to verify (default: every change in the log)
c6aa5bd9 Andy McCall ↶ 465
        change: Option<String>,
2c9ddac3 Andy McCall ↶ 466
        /// Verify every change a revset selects: `release..main & unsigned()`
467
        #[arg(short = 'r', long, value_name = "REVSET", conflicts_with = "change")]
468
        revset: Option<String>,
d42369ab Andy McCall 469
        /// Machine-readable output: one JSON document on stdout
c6aa5bd9 Andy McCall ↶ 470
        #[arg(long)]
471
        json: bool,
472
    },
79ab8528 Andy McCall ↶ 473
    /// Git interoperability
474
    Git {
475
        #[command(subcommand)]
476
        cmd: GitCmd,
477
    },
83e0677b Andy McCall ↶ 478
    /// Manage the trust policy (who may update which bookmarks)
479
    Policy {
480
        #[command(subcommand)]
481
        cmd: PolicyCmd,
482
    },
ff1f62fe Andy McCall ↶ 483
    /// Set a configuration key (author.*, core.sign, core.op-retention, core.gc-grace, core.checkpoint-interval, filter.max-blob, filter.paths, workspace.bookmark, remote.<name>.url|token|ca, auth.helper with --user)
fce44ae9 Andy McCall ↶ 484
    Config {
d42369ab Andy McCall 485
        /// The key, such as author.name or remote.origin.token
fce44ae9 Andy McCall ↶ 486
        key: String,
614f55e1 Andy McCall ↶ 487
        /// The value to set (none with --unset)
488
        #[arg(required_unless_present = "unset")]
489
        value: Option<String>,
fce44ae9 Andy McCall ↶ 490
        /// Write to the user file (~/.config/oxy/config.toml) instead of this repository
491
        #[arg(long)]
492
        user: bool,
614f55e1 Andy McCall ↶ 493
        /// Remove the key from this repository's file (or the user file with --user)
494
        #[arg(long)]
495
        unset: bool,
fce44ae9 Andy McCall ↶ 496
    },
497
}
498
499
#[derive(Subcommand)]
500
enum OpCmd {
98a1620a Andy McCall ↶ 501
    /// List operations, newest first, with what each changed
c6aa5bd9 Andy McCall ↶ 502
    Log {
98a1620a Andy McCall ↶ 503
        /// Show only the latest N (snapshots folded together count as one)
504
        #[arg(short = 'n', long)]
505
        limit: Option<usize>,
d42369ab Andy McCall 506
        /// Machine-readable output: one JSON document on stdout
c6aa5bd9 Andy McCall ↶ 507
        #[arg(long)]
508
        json: bool,
98a1620a Andy McCall ↶ 509
    },
510
    /// Go back to the bookmarks and working copy as they were after OP (recorded as a new operation, so it can be undone)
511
    Restore {
512
        /// The operation: an ID prefix from oxy op log, @ or @-
513
        op: String,
514
        /// Throw away uncommitted working-copy changes
515
        #[arg(long)]
516
        discard: bool,
517
    },
518
    /// Undo OP alone, keeping every operation after it: the bookmarks it moved go back
519
    Revert {
520
        /// The operation: an ID prefix from oxy op log
521
        op: String,
c6aa5bd9 Andy McCall ↶ 522
    },
fce44ae9 Andy McCall ↶ 523
}
524
525
#[derive(Subcommand)]
4e88e774 Andy McCall ↶ 526
enum WorkspaceCmd {
527
    /// Create a workspace at PATH checked out on CHANGE... (default: the bookmark heads)
d42369ab Andy McCall 528
    Add {
529
        /// Directory for the new workspace (must be empty or absent)
530
        path: PathBuf,
531
        /// Changes whose state to check out there
532
        changes: Vec<String>,
533
    },
534
    /// List workspaces and their working-copy changes
1196b29b Andy McCall ↶ 535
    List {
d42369ab Andy McCall 536
        /// Machine-readable output: one JSON document on stdout
1196b29b Andy McCall ↶ 537
        #[arg(long)]
538
        json: bool,
539
    },
4e88e774 Andy McCall ↶ 540
    /// Stop tracking a workspace (by id prefix or path); its files stay
d42369ab Andy McCall 541
    Forget {
542
        /// Workspace id prefix or path
543
        workspace: String,
544
    },
4e88e774 Andy McCall ↶ 545
}
546
547
#[derive(Subcommand)]
957fee30 Andy McCall ↶ 548
enum BisectCmd {
549
    /// Begin; remembers where the working copy was
550
    Start,
551
    /// Mark CHANGE... (or the state under test) as good
d42369ab Andy McCall 552
    Good {
553
        /// Changes known to be good (default: the state under test)
554
        changes: Vec<String>,
555
    },
957fee30 Andy McCall ↶ 556
    /// Mark CHANGE... (or the state under test) as bad
d42369ab Andy McCall 557
    Bad {
558
        /// Changes known to be bad (default: the state under test)
559
        changes: Vec<String>,
560
    },
957fee30 Andy McCall ↶ 561
    /// The state under test cannot be tested; try another
562
    Skip,
563
    /// Run a command for each step: exit 0 good, 125 skip, else bad
564
    Run {
d42369ab Andy McCall 565
        /// Command and arguments to run at each step
957fee30 Andy McCall ↶ 566
        #[arg(required = true, trailing_var_arg = true)]
567
        command: Vec<String>,
568
    },
569
    /// Where the search stands
c6aa5bd9 Andy McCall ↶ 570
    Status {
d42369ab Andy McCall 571
        /// Machine-readable output: one JSON document on stdout
c6aa5bd9 Andy McCall ↶ 572
        #[arg(long)]
573
        json: bool,
574
    },
957fee30 Andy McCall ↶ 575
    /// Restore the working copy and forget the search
576
    Reset,
577
}
578
579
#[derive(Subcommand)]
7b9809e6 Andy McCall ↶ 580
enum BookmarkCmd {
581
    /// Create a bookmark at CHANGE... (default: the working copy's base)
d42369ab Andy McCall 582
    Create {
583
        /// Name of the new bookmark
584
        name: String,
4fe7d604 Andy McCall ↶ 585
        /// Its heads (default: the working copy's base). A state is its
586
        /// heads and what they depend on: a change alone may leave out
587
        /// earlier changes of the current state, which is refused unless
588
        /// --upto or --only says which is meant
d42369ab Andy McCall 589
        changes: Vec<String>,
4fe7d604 Andy McCall ↶ 590
        /// Everything of the current state up to CHANGE..., as a Git
591
        /// branch at a commit would hold
592
        #[arg(long, conflicts_with = "only")]
593
        upto: bool,
594
        /// Just CHANGE... and what they depend on
595
        #[arg(long)]
596
        only: bool,
d42369ab Andy McCall 597
    },
7b9809e6 Andy McCall ↶ 598
    /// Point an existing bookmark at CHANGE...
d42369ab Andy McCall 599
    Set {
600
        /// The bookmark to move
601
        name: String,
06d16dc2 Andy McCall ↶ 602
        /// Its new heads. A change alone may leave out changes the
603
        /// bookmark now holds that were recorded before it, which is
604
        /// refused unless --upto or --only says which is meant
d42369ab Andy McCall 605
        changes: Vec<String>,
06d16dc2 Andy McCall ↶ 606
        /// Everything the bookmark holds up to CHANGE..., as a Git branch
607
        /// moved to a commit would hold
608
        #[arg(long, conflicts_with = "only")]
609
        upto: bool,
610
        /// Just CHANGE... and what they depend on
611
        #[arg(long)]
612
        only: bool,
d42369ab Andy McCall 613
    },
7b9809e6 Andy McCall ↶ 614
    /// Remove a bookmark; its changes stay
d42369ab Andy McCall 615
    Delete {
616
        /// The bookmark to remove
617
        name: String,
618
    },
7b9809e6 Andy McCall ↶ 619
    /// List bookmarks with their heads and difference from origin
c6aa5bd9 Andy McCall ↶ 620
    List {
14edbaaf Andy McCall ↶ 621
        /// Also list remotes' bookmarks that have no local bookmark
622
        #[arg(long, short)]
623
        all: bool,
bf3a6781 Andy McCall ↶ 624
        /// Each head of every bookmark, as `bookmark show` prints them
625
        #[arg(long, short)]
626
        verbose: bool,
d42369ab Andy McCall 627
        /// Machine-readable output: one JSON document on stdout
c6aa5bd9 Andy McCall ↶ 628
        #[arg(long)]
629
        json: bool,
630
    },
bf3a6781 Andy McCall ↶ 631
    /// A bookmark's heads: each change nothing else on it depends on,
632
    /// newest first. A bookmark name is also a revset for its heads
633
    /// (`oxy log -r NAME`, or `bookmark(NAME)` to mean only the bookmark)
634
    Show {
635
        /// The bookmark, or REMOTE/NAME (default: the current one)
636
        name: Option<String>,
637
        /// Machine-readable output: one JSON document on stdout
638
        #[arg(long)]
639
        json: bool,
640
    },
61e3bce7 Andy McCall ↶ 641
    /// Make NAME this workspace's bookmark and check it out. Uncommitted work stops it; --carry takes the work along, --discard drops it
7b9809e6 Andy McCall ↶ 642
    Switch {
14edbaaf Andy McCall ↶ 643
        /// The bookmark to work on; one only a remote has (NAME or REMOTE/NAME) is created from it
7b9809e6 Andy McCall ↶ 644
        name: String,
645
        /// Throw away uncommitted working-copy changes
646
        #[arg(long)]
647
        discard: bool,
61e3bce7 Andy McCall ↶ 648
        /// Take uncommitted changes along; refused when NAME has other
649
        /// versions of the files they touch
650
        #[arg(long, conflicts_with = "discard")]
651
        carry: bool,
ff1f62fe Andy McCall ↶ 652
    },
653
}
654
655
#[derive(Subcommand)]
656
enum AuthCmd {
657
    /// Sign in to HUB in the browser (device sign-in) and keep the token for
658
    /// every repository there
659
    Login {
660
        /// The hub, as https://oxygenhub.io or oxygenhub.io (default: this checkout's origin)
661
        hub: Option<String>,
662
        /// Read a token from standard input instead (for CI and scripts)
663
        #[arg(long)]
664
        with_token: bool,
665
        /// PEM file of extra roots to trust (a hub with a self-signed certificate)
666
        #[arg(long)]
667
        ca: Option<PathBuf>,
7b9809e6 Andy McCall ↶ 668
    },
ff1f62fe Andy McCall ↶ 669
    /// List the hubs you are signed in to, checking each token with its hub
670
    Status,
671
    /// Forget HUB's token and revoke it on the hub
672
    Logout {
673
        /// The hub (default: this checkout's origin, or the only one)
674
        hub: Option<String>,
675
    },
7b9809e6 Andy McCall ↶ 676
}
677
678
#[derive(Subcommand)]
4dee277c Andy McCall ↶ 679
enum SubmoduleCmd {
680
    /// Clone URL (Oxygen or Git) into PATH and register it in .oxymodules
681
    Add {
d42369ab Andy McCall 682
        /// URL or path of the Oxygen or Git repository
4dee277c Andy McCall ↶ 683
        url: String,
d42369ab Andy McCall 684
        /// Where to put it, relative to the repository root
4dee277c Andy McCall ↶ 685
        path: String,
686
        /// Bookmark (Oxygen) or branch (Git) to check out and track
687
        #[arg(long)]
688
        bookmark: Option<String>,
689
    },
690
    /// Bring nested repositories to their pins
691
    Update {
692
        /// Clone nested repositories that are absent
693
        #[arg(long)]
694
        init: bool,
d42369ab Andy McCall 695
        /// Subrepos to update (default: all)
4dee277c Andy McCall ↶ 696
        paths: Vec<String>,
697
    },
698
    /// List subrepos with their pins and on-disk state
c6aa5bd9 Andy McCall ↶ 699
    Status {
d42369ab Andy McCall 700
        /// Machine-readable output: one JSON document on stdout
c6aa5bd9 Andy McCall ↶ 701
        #[arg(long)]
702
        json: bool,
703
    },
4dee277c Andy McCall ↶ 704
    /// Unregister PATH; the directory stays, the node goes with the next commit
d42369ab Andy McCall 705
    Remove {
706
        /// The subrepo to unregister
707
        path: String,
708
    },
4dee277c Andy McCall ↶ 709
}
710
711
#[derive(Subcommand)]
fc1a466a Andy McCall ↶ 712
enum ReceiptCmd {
713
    /// The receipts kept for a state (default: the bookmark heads)
714
    List {
715
        /// Change, bookmark or tag whose state to look at
716
        rev: Option<String>,
717
        /// Machine-readable output: one JSON document on stdout
718
        #[arg(long)]
719
        json: bool,
720
    },
721
    /// One receipt in full, and whether its signature verifies
722
    Show {
723
        /// The receipt (a prefix of its hash, as `list` shows it)
724
        receipt: String,
725
        /// Change, bookmark or tag whose state holds it
726
        #[arg(long)]
727
        rev: Option<String>,
728
        /// Machine-readable output: one JSON document on stdout
729
        #[arg(long)]
730
        json: bool,
731
    },
732
    /// Write a signed receipt to FILE
733
    Export {
734
        /// The receipt (a prefix of its hash, as `list` shows it)
735
        receipt: String,
736
        /// Where to write it
737
        file: String,
738
        /// Change, bookmark or tag whose state holds it
739
        #[arg(long)]
740
        rev: Option<String>,
741
    },
742
    /// Check a signed receipt in FILE without keeping it
743
    Verify {
744
        /// A signed receipt, as a runner or `export` writes it
745
        file: String,
746
        /// Machine-readable output: one JSON document on stdout
747
        #[arg(long)]
748
        json: bool,
749
    },
750
    /// Verify a signed receipt in FILE and keep it with its state
751
    Import {
752
        /// A signed receipt, as a runner or `export` writes it
753
        file: String,
754
    },
755
}
756
757
#[derive(Subcommand)]
132b884b Andy McCall ↶ 758
enum TagCmd {
759
    /// Tag the state of CHANGE... (default: the bookmark heads)
760
    Create {
d42369ab Andy McCall 761
        /// Name of the tag; tags never move
132b884b Andy McCall ↶ 762
        name: String,
d42369ab Andy McCall 763
        /// Changes whose state to tag (default: the bookmark heads)
132b884b Andy McCall ↶ 764
        changes: Vec<String>,
d42369ab Andy McCall 765
        /// A message recorded with the tag
132b884b Andy McCall ↶ 766
        #[arg(short, long, default_value = "")]
767
        message: String,
768
    },
d42369ab Andy McCall 769
    /// List tags and the states they name
1196b29b Andy McCall ↶ 770
    List {
d42369ab Andy McCall 771
        /// Machine-readable output: one JSON document on stdout
1196b29b Andy McCall ↶ 772
        #[arg(long)]
773
        json: bool,
774
    },
132b884b Andy McCall ↶ 775
}
776
777
#[derive(Subcommand)]
fce44ae9 Andy McCall ↶ 778
enum RemoteCmd {
d42369ab Andy McCall 779
    /// Add a remote
75167672 Andy McCall 780
    Add {
d42369ab Andy McCall 781
        /// Name to refer to the remote by, such as origin
75167672 Andy McCall 782
        name: String,
9aa39904 Andy McCall ↶ 783
        /// A local path or the http(s) URL of a hub repository; or a store the repository is kept on: s3://BUCKET/PREFIX, gs://BUCKET/PREFIX, az://ACCOUNT/CONTAINER/PREFIX, dir://PATH
75167672 Andy McCall 784
        url: String,
9aa39904 Andy McCall ↶ 785
        /// For an s3:// store: the AWS profile to use (default: AWS_PROFILE, else "default")
786
        #[arg(long)]
787
        profile: Option<String>,
788
        /// For an s3:// store: its region (default: the environment, the profile, else asked of S3)
789
        #[arg(long)]
790
        region: Option<String>,
791
        /// For an s3://, gs:// or az:// store: another endpoint, such as an S3-compatible service
792
        #[arg(long)]
793
        endpoint: Option<String>,
794
        /// For a gs:// store: a service account key file, or application default credentials
795
        #[arg(long)]
796
        credentials: Option<String>,
75167672 Andy McCall 797
    },
9aa39904 Andy McCall ↶ 798
    /// Check a remote: that it is reachable with the credentials in hand, what it holds, and (for a store) that it behaves
799
    Check {
800
        /// The remote to check
801
        name: String,
802
    },
d42369ab Andy McCall 803
    /// Remove a remote
75167672 Andy McCall 804
    Remove {
d42369ab Andy McCall 805
        /// The remote to remove
75167672 Andy McCall 806
        name: String,
807
    },
d42369ab Andy McCall 808
    /// List remotes and their URLs
c6aa5bd9 Andy McCall ↶ 809
    List {
d42369ab Andy McCall 810
        /// Machine-readable output: one JSON document on stdout
c6aa5bd9 Andy McCall ↶ 811
        #[arg(long)]
812
        json: bool,
813
    },
fce44ae9 Andy McCall ↶ 814
}
815
816
#[derive(Subcommand)]
d82e4409 Andy McCall ↶ 817
enum ProposalCmd {
818
    /// Show a proposal by its hub URL
819
    Show {
d42369ab Andy McCall 820
        /// The proposal's URL on the hub
d82e4409 Andy McCall ↶ 821
        url: String,
d42369ab Andy McCall 822
        /// Machine-readable output: one JSON document on stdout
d82e4409 Andy McCall ↶ 823
        #[arg(long)]
824
        json: bool,
825
    },
826
    /// Fetch the proposal's changes, set the target bookmark to the projected state, and push with your key
827
    Land {
d42369ab Andy McCall 828
        /// The proposal's URL on the hub
d82e4409 Andy McCall ↶ 829
        url: String,
830
        /// Land even when the hub reports blockers
831
        #[arg(long)]
832
        force: bool,
833
    },
834
}
835
836
#[derive(Subcommand)]
fce44ae9 Andy McCall ↶ 837
enum IdentityCmd {
838
    /// Generate a composite Ed25519 + ML-DSA-65 key pair and make it your author identity
839
    Create {
d42369ab Andy McCall 840
        /// Your name (default: author.name)
fce44ae9 Andy McCall ↶ 841
        #[arg(long)]
842
        name: Option<String>,
d42369ab Andy McCall 843
        /// Your email (default: author.email)
fce44ae9 Andy McCall ↶ 844
        #[arg(long)]
845
        email: Option<String>,
846
        /// Record the author in this repository only, not in the user config
847
        #[arg(long)]
848
        local: bool,
28fc23d7 Andy McCall ↶ 849
        /// Expire the identity this many days from now
850
        #[arg(long)]
851
        expires: Option<u64>,
fce44ae9 Andy McCall ↶ 852
    },
853
    /// Show the configured identity
854
    Show,
83e0677b Andy McCall ↶ 855
    /// Write your identity object to a file, to hand to a policy holder
d42369ab Andy McCall 856
    Export {
e3d071ce Andy McCall ↶ 857
        /// File to write (default: <key>.identity in the current directory)
d42369ab Andy McCall 858
        path: Option<PathBuf>,
859
    },
7aa2dc93 Andy McCall ↶ 860
    /// Sign a host's challenge (hex, at least 16 bytes) to prove you hold your key; prints the signature as hex
861
    SignChallenge {
d42369ab Andy McCall 862
        /// The host's challenge, as hex
7aa2dc93 Andy McCall ↶ 863
        challenge: String,
d42369ab Andy McCall 864
        /// Machine-readable output: one JSON document on stdout
7aa2dc93 Andy McCall ↶ 865
        #[arg(long)]
866
        json: bool,
867
    },
28fc23d7 Andy McCall ↶ 868
    /// Move to a fresh key pair; the policy follows if it names your key
869
    Rotate,
870
    /// Re-issue your identity with a new expiry (in days from now; 0 = never)
871
    Renew {
d42369ab Andy McCall 872
        /// Days from now until it expires; 0 for never
28fc23d7 Andy McCall ↶ 873
        #[arg(long)]
874
        expires: u64,
875
    },
876
    /// Revoke a key: yours by default, or any key if you hold a policy root
877
    Revoke {
878
        /// KeyId prefix (default: your own key)
879
        key: Option<String>,
d42369ab Andy McCall 880
        /// Why, recorded in the revocation
28fc23d7 Andy McCall ↶ 881
        #[arg(long, default_value = "")]
882
        reason: String,
883
    },
884
    /// Keys allowed to sign or seal on your behalf
885
    Delegate {
886
        #[command(subcommand)]
887
        cmd: DelegateCmd,
888
    },
889
}
890
891
#[derive(Subcommand)]
892
enum DelegateCmd {
893
    /// Add a delegate from an exported identity file
d42369ab Andy McCall 894
    Add {
614f55e1 Andy McCall ↶ 895
        /// The delegates' exported identity files: one rotation for all of them
896
        #[arg(required = true)]
897
        identity_file: Vec<PathBuf>,
7ba155f2 Andy McCall ↶ 898
        /// What it may do for you: changes, refs, seal (comma-separated) or all.
899
        /// An agent gets `changes`; a host that lands for you needs `changes,refs`
900
        #[arg(long, default_value = "changes")]
901
        scope: String,
902
        /// How long for: 30m, 8h, 7d, or a number of days (default: until removed)
903
        #[arg(long)]
904
        expires: Option<String>,
d42369ab Andy McCall 905
    },
28fc23d7 Andy McCall ↶ 906
    /// Remove a delegate by KeyId prefix
d42369ab Andy McCall 907
    Remove {
908
        /// KeyId prefix of the delegate
909
        key: String,
910
    },
28fc23d7 Andy McCall ↶ 911
    /// List delegates
912
    List,
fce44ae9 Andy McCall ↶ 913
}
914
83e0677b Andy McCall ↶ 915
#[derive(Subcommand)]
79ab8528 Andy McCall ↶ 916
enum GitCmd {
917
    /// Export the current bookmark to a Git repository (created bare if absent)
30ea9c1e Andy McCall ↶ 918
    Export {
d42369ab Andy McCall 919
        /// Git repository to write to (created bare if absent)
30ea9c1e Andy McCall ↶ 920
        git_dir: PathBuf,
921
        /// Git branch to write (default: the bookmark name)
922
        #[arg(long)]
923
        branch: Option<String>,
924
    },
925
    /// Fetch a branch from a Git remote (path or URL) into the current bookmark
926
    Fetch {
d42369ab Andy McCall 927
        /// Git remote: a path or URL
30ea9c1e Andy McCall ↶ 928
        url: String,
d42369ab Andy McCall 929
        /// Branch to fetch
30ea9c1e Andy McCall ↶ 930
        #[arg(long, default_value = "main")]
931
        branch: String,
d6e0d5b8 Andy McCall ↶ 932
        /// Author your own commits (Git author email = your identity's) with your key; sets git.claim
933
        #[arg(long)]
934
        claim: bool,
30ea9c1e Andy McCall ↶ 935
    },
936
    /// Push the current bookmark to a branch of a Git remote (fetch first)
937
    Push {
d42369ab Andy McCall 938
        /// Git remote: a path or URL
30ea9c1e Andy McCall ↶ 939
        url: String,
d42369ab Andy McCall 940
        /// Branch to push to
30ea9c1e Andy McCall ↶ 941
        #[arg(long, default_value = "main")]
942
        branch: String,
943
    },
54e2e630 Andy McCall ↶ 944
    /// Recover an import that stopped before it moved the bookmark: point the bookmark at every imported commit's change in the store, so oxy git fetch carries on from there
945
    Recover,
62794ecc Andy McCall ↶ 946
    /// Check this repository's import of a Git branch: every commit's tree must be reproduced exactly
947
    Verify {
948
        /// The Git repository the import came from
949
        git_dir: PathBuf,
950
        /// Branch that was imported
951
        #[arg(long, default_value = "main")]
952
        branch: String,
953
    },
c3069537 Andy McCall ↶ 954
    /// Import a Git branch into a new Oxygen repository at DEST
955
    Import {
d42369ab Andy McCall 956
        /// Git repository to read
c3069537 Andy McCall ↶ 957
        git_dir: PathBuf,
d42369ab Andy McCall 958
        /// Directory for the new Oxygen repository
c3069537 Andy McCall ↶ 959
        dest: PathBuf,
d42369ab Andy McCall 960
        /// Branch to import
c3069537 Andy McCall ↶ 961
        #[arg(long, default_value = "main")]
962
        branch: String,
d6e0d5b8 Andy McCall ↶ 963
        /// Author your own commits (Git author email = your identity's) with your key; sets git.claim
964
        #[arg(long)]
965
        claim: bool,
c3069537 Andy McCall ↶ 966
    },
79ab8528 Andy McCall ↶ 967
}
968
969
#[derive(Subcommand)]
83e0677b Andy McCall ↶ 970
enum PolicyCmd {
971
    /// Create the initial policy with your identity as the only root
972
    Init,
973
    /// Show the current policy
c6aa5bd9 Andy McCall ↶ 974
    Show {
d42369ab Andy McCall 975
        /// Machine-readable output: one JSON document on stdout
c6aa5bd9 Andy McCall ↶ 976
        #[arg(long)]
977
        json: bool,
978
    },
83e0677b Andy McCall ↶ 979
    /// Allow an identity (from `oxy identity export`) to update bookmarks
980
    Grant {
d42369ab Andy McCall 981
        /// The identity to grant, exported with `oxy identity export`
83e0677b Andy McCall ↶ 982
        identity_file: PathBuf,
983
        /// Reference pattern the grant applies to (default: every bookmark)
984
        #[arg(long)]
985
        pattern: Option<String>,
28fc23d7 Andy McCall ↶ 986
        /// Where to write the proposal when more root signatures are needed
987
        #[arg(long)]
988
        out: Option<PathBuf>,
83e0677b Andy McCall ↶ 989
    },
990
    /// Revoke a key (KeyId prefix of an identity in the policy)
28fc23d7 Andy McCall ↶ 991
    Revoke {
d42369ab Andy McCall 992
        /// KeyId prefix of the identity
28fc23d7 Andy McCall ↶ 993
        key: String,
994
        /// Where to write the proposal when more root signatures are needed
995
        #[arg(long)]
996
        out: Option<PathBuf>,
997
    },
998
    /// Manage root keys and the signature threshold for policy updates
999
    Root {
1000
        #[command(subcommand)]
1001
        cmd: RootCmd,
1002
    },
1003
    /// Add your root signature to a proposal file; applies it once the threshold is met
1004
    Sign {
d42369ab Andy McCall 1005
        /// The proposal file to sign
28fc23d7 Andy McCall ↶ 1006
        proposal: PathBuf,
1007
        /// Where to write the proposal if it still needs signatures (default: in place)
1008
        #[arg(long)]
1009
        out: Option<PathBuf>,
1010
    },
1011
}
1012
1013
#[derive(Subcommand)]
1014
enum RootCmd {
1015
    /// Make an exported identity a root key
1016
    Add {
d42369ab Andy McCall 1017
        /// The identity to make a root, exported with `oxy identity export`
28fc23d7 Andy McCall ↶ 1018
        identity_file: PathBuf,
d42369ab Andy McCall 1019
        /// Where to write the proposal when more root signatures are needed
28fc23d7 Andy McCall ↶ 1020
        #[arg(long)]
1021
        out: Option<PathBuf>,
1022
    },
1023
    /// Remove a root key by KeyId prefix
1024
    Remove {
d42369ab Andy McCall 1025
        /// KeyId prefix of the root key
28fc23d7 Andy McCall ↶ 1026
        key: String,
d42369ab Andy McCall 1027
        /// Where to write the proposal when more root signatures are needed
28fc23d7 Andy McCall ↶ 1028
        #[arg(long)]
1029
        out: Option<PathBuf>,
1030
    },
1031
    /// Require this many root signatures on policy updates
1032
    Threshold {
d42369ab Andy McCall 1033
        /// Number of root signatures
28fc23d7 Andy McCall ↶ 1034
        n: u32,
d42369ab Andy McCall 1035
        /// Where to write the proposal when more root signatures are needed
28fc23d7 Andy McCall ↶ 1036
        #[arg(long)]
1037
        out: Option<PathBuf>,
1038
    },
83e0677b Andy McCall ↶ 1039
}
1040
fce44ae9 Andy McCall ↶ 1041
/// Open the repository containing the current directory.
1042
fn open() -> Result<Repo> {
98a1620a Andy McCall ↶ 1043
    let repo = Repo::open(&std::env::current_dir()?).context("opening repository")?;
1044
    match AT_OP.get().and_then(|o| o.as_deref()) {
1045
        Some(op) => Ok(repo.at_op(op)?),
1046
        None => Ok(repo),
1047
    }
fce44ae9 Andy McCall ↶ 1048
}
1049
d42369ab Andy McCall 1050
/// `oxy man`: every page into `dir`, or the top-level page on stdout.
1051
fn man(dir: Option<PathBuf>) -> Result<i32> {
1052
    use clap::CommandFactory;
1053
    let cmd = Cli::command();
1054
    match dir {
1055
        Some(dir) => {
1056
            std::fs::create_dir_all(&dir)?;
1057
            clap_mangen::generate_to(cmd, &dir)?;
1058
            let pages = std::fs::read_dir(&dir)?
1059
                .filter(|e| {
1060
                    e.as_ref()
1061
                        .is_ok_and(|e| e.path().extension().is_some_and(|x| x == "1"))
1062
                })
1063
                .count();
1064
            println!(
1065
                "{}",
1066
                ui::done(format!("Wrote {pages} man pages to {}", dir.display()))
1067
            );
1068
        }
1069
        None => clap_mangen::Man::new(cmd).render(&mut std::io::stdout())?,
1070
    }
1071
    Ok(0)
1072
}
1073
fce44ae9 Andy McCall ↶ 1074
/// Parse arguments and run; returns the process exit code.
1075
pub fn run() -> Result<i32> {
8d803563 Andy McCall ↶ 1076
    // The cloud stores (s3://, gs://, az://) for remotes kept on them.
1077
    oxy_strata::register();
fce44ae9 Andy McCall ↶ 1078
    let cli = Cli::parse();
135212de Andy McCall ↶ 1079
    ui::init(cli.plain);
98a1620a Andy McCall ↶ 1080
    AT_OP.set(cli.at_op.clone()).ok();
fce44ae9 Andy McCall ↶ 1081
    match cli.cmd {
d42369ab Andy McCall 1082
        Cmd::Completions { shell } => {
1083
            use clap::CommandFactory;
1084
            clap_complete::generate(shell, &mut Cli::command(), "oxy", &mut std::io::stdout());
1085
            Ok(0)
1086
        }
1087
        Cmd::Man { dir } => man(dir),
d069701a Andy McCall ↶ 1088
        Cmd::Init { path, bare, store } => workspace::init(path, bare, store.as_deref()),
50a046e4 Andy McCall ↶ 1089
        Cmd::Status { json } => workspace::status(json),
75167672 Andy McCall 1090
        Cmd::Prompt {
1091
            format,
1092
            glyphs,
1093
            color,
1094
        } => workspace::prompt(&format, glyphs, color.as_deref()),
1095
        Cmd::Commit {
1096
            message,
6a81dbab Andy McCall ↶ 1097
            file,
75167672 Andy McCall 1098
            depends_on,
1099
            paths,
1100
            interactive,
1101
            hunks,
6a81dbab Andy McCall ↶ 1102
        } => {
1103
            let message = match (message, file) {
1104
                (Some(m), _) => m,
1105
                (None, Some(f)) if f.as_os_str() == "-" => {
1106
                    let mut s = String::new();
1107
                    std::io::Read::read_to_string(&mut std::io::stdin(), &mut s)?;
1108
                    s
1109
                }
1110
                (None, Some(f)) => std::fs::read_to_string(&f).map_err(|e| {
1111
                    anyhow::anyhow!("reading the message from {}: {e}", f.display())
1112
                })?,
1113
                (None, None) => anyhow::bail!("a commit message is required (-m or -F)"),
1114
            };
1115
            workspace::commit(&message, &depends_on, &paths, interactive, &hunks)
1116
        }
c6aa5bd9 Andy McCall ↶ 1117
        Cmd::Cat { path, change } => workspace::cat(&path, change.as_deref()),
1118
        Cmd::Root { json } => workspace::root(json),
1119
        Cmd::Version { json } => workspace::version(json),
1120
        Cmd::Discard { paths, hunks } => workspace::discard(&paths, &hunks),
1121
        Cmd::Hunks { json } => workspace::hunks(json),
728da0f9 Andy McCall ↶ 1122
        Cmd::Squash { change, into } => workspace::squash(&change, &into),
e266b7d4 Andy McCall ↶ 1123
        Cmd::Rebase {
1124
            change,
1125
            onto,
1126
            into_working_copy,
1127
        } => workspace::rebase(&change, &onto, into_working_copy),
957fee30 Andy McCall ↶ 1128
        Cmd::Blame { path, json } => workspace::blame(&path, json),
1129
        Cmd::Bisect { cmd } => match cmd {
1130
            BisectCmd::Start => workspace::bisect_start(),
1131
            BisectCmd::Good { changes } => workspace::bisect_mark(Some(true), &changes),
1132
            BisectCmd::Bad { changes } => workspace::bisect_mark(Some(false), &changes),
1133
            BisectCmd::Skip => workspace::bisect_mark(None, &[]),
1134
            BisectCmd::Run { command } => workspace::bisect_run(&command),
c6aa5bd9 Andy McCall ↶ 1135
            BisectCmd::Status { json } => workspace::bisect_status(json),
957fee30 Andy McCall ↶ 1136
            BisectCmd::Reset => workspace::bisect_reset(),
1137
        },
75167672 Andy McCall 1138
        Cmd::Log {
47ce8b8e Andy McCall ↶ 1139
            revset,
75167672 Andy McCall 1140
            limit,
1141
            verbose,
1142
            path,
83d61e80 Andy McCall ↶ 1143
            lines,
75167672 Andy McCall 1144
            json,
47ce8b8e Andy McCall ↶ 1145
        } => workspace::log(
1146
            revset.as_deref(),
1147
            limit,
1148
            verbose,
1149
            path.as_deref(),
1150
            lines.as_deref(),
1151
            json,
1152
        ),
c6aa5bd9 Andy McCall ↶ 1153
        Cmd::Diff { change, json } => workspace::diff(change.as_deref(), json),
6a81dbab Andy McCall ↶ 1154
        Cmd::Describe {
1155
            message,
1156
            change,
1157
            json,
1158
        } => match message {
1159
            Some(m) => workspace::describe(&m, change.as_deref()),
1160
            None if change.is_some() => {
1161
                anyhow::bail!(
1162
                    "naming works on the working copy; to change a head's message pass -m"
1163
                )
1164
            }
1165
            None => workspace::describe_name(json),
1166
        },
23b217d7 Andy McCall ↶ 1167
        Cmd::Amend { message, into } => workspace::amend(message.as_deref(), into.as_deref()),
1168
        Cmd::Split { change, paths } => workspace::split(&change, &paths),
2c9ddac3 Andy McCall ↶ 1169
        Cmd::Abandon {
1170
            change,
1171
            revset,
1172
            yes,
1173
        } => workspace::abandon(change.as_deref(), revset.as_deref(), yes),
1174
        Cmd::Show {
1175
            change,
1176
            revset,
1177
            json,
1178
        } => workspace::show(change.as_deref(), revset.as_deref(), json),
1c2bd9ab Andy McCall ↶ 1179
        Cmd::Checkout {
1180
            changes,
1181
            discard,
1182
            carry,
1183
        } => workspace::checkout(&changes, discard, carry),
c6aa5bd9 Andy McCall ↶ 1184
        Cmd::Resolve { json } => workspace::resolve(json),
fce44ae9 Andy McCall ↶ 1185
        Cmd::Undo => workspace::undo(),
ba160f60 Andy McCall ↶ 1186
        Cmd::Gc { now } => workspace::gc(now),
387335ff Andy McCall ↶ 1187
        Cmd::Fsck { json } => workspace::fsck(json),
3e5772cc Andy McCall ↶ 1188
        Cmd::Doctor { offline, json } => workspace::doctor(offline, json),
252e8cb2 Andy McCall ↶ 1189
        Cmd::Checkpoint => workspace::checkpoint(),
98a1620a Andy McCall ↶ 1190
        Cmd::Op { cmd } => match cmd {
1191
            OpCmd::Log { limit, json } => workspace::op_log(limit, json),
1192
            OpCmd::Restore { op, discard } => workspace::op_restore(&op, discard),
1193
            OpCmd::Revert { op } => workspace::op_revert(&op),
1194
        },
75167672 Andy McCall 1195
        Cmd::Clone {
1196
            url,
1197
            dest,
1198
            max_blob,
1199
            sparse,
1200
            depth,
14edbaaf Andy McCall ↶ 1201
            recursive,
1202
        } => sync::clone(&url, dest, max_blob.as_deref(), &sparse, depth, recursive),
2863456a Andy McCall ↶ 1203
        Cmd::Deepen { depth, remote } => sync::deepen(&remote, depth),
7421309f Andy McCall ↶ 1204
        Cmd::Sparse { paths } => workspace::sparse(&paths),
cdb5beba Andy McCall ↶ 1205
        Cmd::Lock { path } => workspace::lock(&path),
1206
        Cmd::Unlock { path } => workspace::unlock(&path),
4e88e774 Andy McCall ↶ 1207
        Cmd::Workspace { cmd } => match cmd {
1208
            WorkspaceCmd::Add { path, changes } => workspace::workspace_add(&path, &changes),
1196b29b Andy McCall ↶ 1209
            WorkspaceCmd::List { json } => workspace::workspace_list(json),
4e88e774 Andy McCall ↶ 1210
            WorkspaceCmd::Forget { workspace } => workspace::workspace_forget(&workspace),
1211
        },
7b9809e6 Andy McCall ↶ 1212
        Cmd::Bookmark { cmd } => match cmd {
4fe7d604 Andy McCall ↶ 1213
            BookmarkCmd::Create {
1214
                name,
1215
                changes,
1216
                upto,
1217
                only,
1218
            } => workspace::bookmark_create(&name, &changes, upto, only),
06d16dc2 Andy McCall ↶ 1219
            BookmarkCmd::Set {
1220
                name,
1221
                changes,
1222
                upto,
1223
                only,
1224
            } => workspace::bookmark_set(&name, &changes, upto, only),
7b9809e6 Andy McCall ↶ 1225
            BookmarkCmd::Delete { name } => workspace::bookmark_delete(&name),
bf3a6781 Andy McCall ↶ 1226
            BookmarkCmd::List { all, verbose, json } => {
1227
                workspace::bookmark_list(all, verbose, json)
1228
            }
1229
            BookmarkCmd::Show { name, json } => workspace::bookmark_show(name.as_deref(), json),
61e3bce7 Andy McCall ↶ 1230
            BookmarkCmd::Switch {
1231
                name,
1232
                discard,
1233
                carry,
1234
            } => workspace::bookmark_switch(&name, discard, carry),
7b9809e6 Andy McCall ↶ 1235
        },
1236
        Cmd::Merge { bookmark } => workspace::merge(&bookmark),
ff1f62fe Andy McCall ↶ 1237
        Cmd::Auth { cmd } => match cmd {
1238
            AuthCmd::Login {
1239
                hub,
1240
                with_token,
1241
                ca,
1242
            } => auth::login(hub.as_deref(), with_token, ca),
1243
            AuthCmd::Status => auth::status(),
1244
            AuthCmd::Logout { hub } => auth::logout(hub.as_deref()),
1245
        },
4dee277c Andy McCall ↶ 1246
        Cmd::Submodule { cmd } => match cmd {
75167672 Andy McCall 1247
            SubmoduleCmd::Add {
1248
                url,
1249
                path,
1250
                bookmark,
1251
            } => sync::submodule_add(&url, &path, bookmark.as_deref()),
4dee277c Andy McCall ↶ 1252
            SubmoduleCmd::Update { init, paths } => sync::submodule_update(init, &paths),
c6aa5bd9 Andy McCall ↶ 1253
            SubmoduleCmd::Status { json } => sync::submodule_status(json),
4dee277c Andy McCall ↶ 1254
            SubmoduleCmd::Remove { path } => sync::submodule_remove(&path),
fc1a466a Andy McCall ↶ 1255
        },
1256
        Cmd::Receipt { cmd } => match cmd {
1257
            ReceiptCmd::List { rev, json } => receipt::list(rev.as_deref(), json),
1258
            ReceiptCmd::Show {
1259
                receipt: r,
1260
                rev,
1261
                json,
1262
            } => receipt::show(&r, rev.as_deref(), json),
1263
            ReceiptCmd::Export {
1264
                receipt: r,
1265
                file,
1266
                rev,
1267
            } => receipt::export(&r, &file, rev.as_deref()),
1268
            ReceiptCmd::Verify { file, json } => receipt::verify(&file, json),
1269
            ReceiptCmd::Import { file } => receipt::import(&file),
4dee277c Andy McCall ↶ 1270
        },
132b884b Andy McCall ↶ 1271
        Cmd::Tag { cmd } => match cmd {
75167672 Andy McCall 1272
            TagCmd::Create {
1273
                name,
1274
                changes,
1275
                message,
1276
            } => workspace::tag_create(&name, &changes, &message),
1196b29b Andy McCall ↶ 1277
            TagCmd::List { json } => workspace::tag_list(json),
132b884b Andy McCall ↶ 1278
        },
fce44ae9 Andy McCall ↶ 1279
        Cmd::Remote { cmd } => match cmd {
9aa39904 Andy McCall ↶ 1280
            RemoteCmd::Add {
1281
                name,
1282
                url,
1283
                profile,
1284
                region,
1285
                endpoint,
1286
                credentials,
1287
            } => sync::remote_add(
1288
                &name,
1289
                &url,
1290
                &[
1291
                    ("profile", profile),
1292
                    ("region", region),
1293
                    ("endpoint", endpoint),
1294
                    ("credentials", credentials),
1295
                ],
1296
            ),
1297
            RemoteCmd::Check { name } => sync::remote_check(&name),
fce44ae9 Andy McCall ↶ 1298
            RemoteCmd::Remove { name } => sync::remote_remove(&name),
c6aa5bd9 Andy McCall ↶ 1299
            RemoteCmd::List { json } => sync::remote_list(json),
fce44ae9 Andy McCall ↶ 1300
        },
c6aa5bd9 Andy McCall ↶ 1301
        Cmd::Fetch { remote, json } => sync::fetch(remote.as_deref(), json),
1302
        Cmd::Pull { remote, json } => sync::pull(remote.as_deref(), json),
75167672 Andy McCall 1303
        Cmd::Push {
1304
            remote,
1305
            force,
1306
            bookmark,
f8c69576 Andy McCall ↶ 1307
            delete,
75167672 Andy McCall 1308
            json,
f8c69576 Andy McCall ↶ 1309
        } => match delete {
1310
            Some(name) => sync::push_delete(remote.as_deref(), &name, json),
1311
            None => sync::push(remote.as_deref(), force, bookmark.as_deref(), json),
1312
        },
75167672 Andy McCall 1313
        Cmd::Serve {
1314
            root,
1315
            bind,
1316
            tokens,
1317
            tls_cert,
1318
            tls_key,
1319
        } => sync::serve(root, &bind, tokens, tls_cert.zip(tls_key)),
fce44ae9 Andy McCall ↶ 1320
        Cmd::Identity { cmd } => match cmd {
75167672 Andy McCall 1321
            IdentityCmd::Create {
1322
                name,
1323
                email,
1324
                local,
1325
                expires,
1326
            } => identity::create(name, email, local, expires),
fce44ae9 Andy McCall ↶ 1327
            IdentityCmd::Show => identity::show(),
83e0677b Andy McCall ↶ 1328
            IdentityCmd::Export { path } => identity::export(path),
119bbf50 Andy McCall ↶ 1329
            IdentityCmd::SignChallenge { challenge, json } => {
1330
                identity::sign_challenge(&challenge, json)
1331
            }
28fc23d7 Andy McCall ↶ 1332
            IdentityCmd::Rotate => identity::rotate(),
1333
            IdentityCmd::Renew { expires } => identity::renew(expires),
1334
            IdentityCmd::Revoke { key, reason } => identity::revoke(key.as_deref(), &reason),
1335
            IdentityCmd::Delegate { cmd } => match cmd {
7ba155f2 Andy McCall ↶ 1336
                DelegateCmd::Add {
1337
                    identity_file,
1338
                    scope,
1339
                    expires,
1340
                } => identity::delegate_add(&identity_file, &scope, expires.as_deref()),
28fc23d7 Andy McCall ↶ 1341
                DelegateCmd::Remove { key } => identity::delegate_remove(&key),
1342
                DelegateCmd::List => identity::delegate_list(),
1343
            },
83e0677b Andy McCall ↶ 1344
        },
75167672 Andy McCall 1345
        Cmd::Git {
1346
            cmd: GitCmd::Export { git_dir, branch },
1347
        } => sync::git_export(&git_dir, branch.as_deref()),
1348
        Cmd::Git {
d6e0d5b8 Andy McCall ↶ 1349
            cmd: GitCmd::Fetch { url, branch, claim },
1350
        } => sync::git_fetch(&url, &branch, claim),
75167672 Andy McCall 1351
        Cmd::Git {
1352
            cmd: GitCmd::Push { url, branch },
1353
        } => sync::git_push(&url, &branch),
1354
        Cmd::Git {
54e2e630 Andy McCall ↶ 1355
            cmd: GitCmd::Recover,
1356
        } => sync::git_recover(),
1357
        Cmd::Git {
75167672 Andy McCall 1358
            cmd:
1359
                GitCmd::Import {
1360
                    git_dir,
1361
                    dest,
1362
                    branch,
d6e0d5b8 Andy McCall ↶ 1363
                    claim,
75167672 Andy McCall 1364
                },
d6e0d5b8 Andy McCall ↶ 1365
        } => sync::git_import(&git_dir, &dest, &branch, claim),
62794ecc Andy McCall ↶ 1366
        Cmd::Git {
1367
            cmd: GitCmd::Verify { git_dir, branch },
1368
        } => sync::git_verify(&git_dir, &branch),
83e0677b Andy McCall ↶ 1369
        Cmd::Policy { cmd } => match cmd {
1370
            PolicyCmd::Init => identity::policy_init(),
c6aa5bd9 Andy McCall ↶ 1371
            PolicyCmd::Show { json } => identity::policy_show(json),
75167672 Andy McCall 1372
            PolicyCmd::Grant {
1373
                identity_file,
1374
                pattern,
1375
                out,
1376
            } => identity::policy_grant(&identity_file, pattern.as_deref(), out),
28fc23d7 Andy McCall ↶ 1377
            PolicyCmd::Revoke { key, out } => identity::policy_revoke(&key, out),
1378
            PolicyCmd::Root { cmd } => match cmd {
75167672 Andy McCall 1379
                RootCmd::Add { identity_file, out } => {
1380
                    identity::policy_root_add(&identity_file, out)
1381
                }
28fc23d7 Andy McCall ↶ 1382
                RootCmd::Remove { key, out } => identity::policy_root_remove(&key, out),
1383
                RootCmd::Threshold { n, out } => identity::policy_threshold(n, out),
1384
            },
1385
            PolicyCmd::Sign { proposal, out } => identity::policy_sign(&proposal, out),
fce44ae9 Andy McCall ↶ 1386
        },
4213c41d Andy McCall ↶ 1387
        Cmd::Seal {
1388
            changes,
1389
            proposal: Some(url),
1390
            json,
1391
        } if changes.is_empty() => proposal::seal(&url, json),
d82e4409 Andy McCall ↶ 1392
        Cmd::Seal { changes, json, .. } => identity::seal(&changes, json),
1393
        Cmd::Proposal { cmd } => match cmd {
1394
            ProposalCmd::Show { url, json } => proposal::show(&url, json),
1395
            ProposalCmd::Land { url, force } => proposal::land(&url, force),
1396
        },
2c9ddac3 Andy McCall ↶ 1397
        Cmd::Verify {
1398
            change,
1399
            revset,
1400
            json,
1401
        } => identity::verify(change.as_deref(), revset.as_deref(), json),
614f55e1 Andy McCall ↶ 1402
        Cmd::Config {
1403
            key,
1404
            value,
1405
            user,
1406
            unset,
1407
        } => identity::config(&key, value.as_deref().unwrap_or(""), user, unset),
fce44ae9 Andy McCall ↶ 1408
    }
1409
}
d42369ab Andy McCall 1410
1411
#[cfg(test)]
1412
mod help_tests {
1413
    use super::Cli;
1414
    use clap::CommandFactory;
1415
1416
    /// Every command and every argument explains itself, so `--help`,
1417
    /// completions and the man pages are complete.
1418
    #[test]
1419
    fn every_command_and_argument_has_help() {
1420
        fn walk(cmd: &clap::Command, path: &str, missing: &mut Vec<String>) {
1421
            let here = format!("{path} {}", cmd.get_name()).trim().to_string();
1422
            if cmd.get_about().is_none() && path != "" {
1423
                missing.push(format!("{here} (command)"));
1424
            }
1425
            for a in cmd.get_arguments() {
1426
                let id = a.get_id().as_str();
1427
                if id == "help" || id == "version" || a.is_global_set() && path != "" {
1428
                    continue;
1429
                }
1430
                if a.get_help().is_none() && a.get_long_help().is_none() {
1431
                    missing.push(format!("{here} {id}"));
1432
                }
1433
            }
1434
            for sub in cmd.get_subcommands() {
1435
                walk(sub, &here, missing);
1436
            }
1437
        }
1438
        let mut missing = Vec::new();
1439
        walk(&Cli::command(), "", &mut missing);
1440
        assert!(
1441
            missing.is_empty(),
1442
            "{} without help:\n{}",
1443
            missing.len(),
1444
            missing.join("\n")
1445
        );
1446
    }
1447
}