OXYGENHUB
# 07eb99be126e oxygen / src / cli / mod.rs
25.3 KiB · Rust · last changed Unbound hosted repositories adopt the first pusher's id 1 month ago source blame history raw
1
//! Command-line definitions and dispatch.
2
3
mod format;
4
mod identity;
5
mod json;
6
mod sync;
7
pub mod ui;
8
mod workspace;
9
10
use anyhow::{Context, Result};
11
use clap::{Parser, Subcommand};
12
use oxy_core::repo::Repo;
13
use std::path::PathBuf;
14
15
#[derive(Parser)]
16
#[command(
17
    name = "oxy",
18
    version,
19
    about = "Oxygen: breathing fresh air into version control"
20
)]
21
struct Cli {
22
    /// Plain output: no colour, no spinner (also implied by NO_COLOR or a non-terminal)
23
    #[arg(long, global = true)]
24
    plain: bool,
25
    #[command(subcommand)]
26
    cmd: Cmd,
27
}
28
29
#[derive(Subcommand)]
30
enum Cmd {
31
    /// Create a repository in PATH (default: current directory)
32
    Init {
33
        path: Option<PathBuf>,
34
        /// No working copy: an object store and references only, for hosting
35
        #[arg(long)]
36
        bare: bool,
37
    },
38
    /// Clone a repository from a local path or an http(s) URL
39
    Clone {
40
        url: String,
41
        dest: Option<PathBuf>,
42
        /// Leave blobs larger than this (e.g. 1M) to be fetched on first read
43
        #[arg(long)]
44
        max_blob: Option<String>,
45
        /// Materialize only these paths (repeatable); implies lazy blobs
46
        #[arg(long = "sparse")]
47
        sparse: Vec<String>,
48
        /// Shallow clone: fetch only this many levels of history below the heads
49
        #[arg(long)]
50
        depth: Option<u32>,
51
    },
52
    /// Fetch more history below a shallow clone's boundary
53
    Deepen {
54
        #[arg(default_value_t = 10)]
55
        depth: u32,
56
        #[arg(long, default_value = "origin")]
57
        remote: String,
58
    },
59
    /// Show or set the sparse filter (paths to materialize); re-checks out the bookmark
60
    Sparse { paths: Vec<String> },
61
    /// Show the working copy: changed paths and conflicts
62
    Status {
63
        /// Machine-readable output: paths, and every conflict with its kind and contributing changes
64
        #[arg(long)]
65
        json: bool,
66
    },
67
    /// One-line summary for shell prompts; fast and records nothing
68
    Prompt {
69
        /// 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
70
        #[arg(long, default_value = oxy_core::repo::DEFAULT_PROMPT_FORMAT)]
71
        format: String,
72
        /// Glyph format (%i %b %c %s%U%O) instead of the plain default
73
        #[arg(long)]
74
        glyphs: bool,
75
        /// Colour by state (cyan clean, yellow dirty, red conflicted): raw escapes, or guarded for a bash or zsh PS1
76
        #[arg(long, value_parser = ["raw", "bash", "zsh"])]
77
        color: Option<String>,
78
    },
79
    /// Record the working copy as a change on the current bookmark
80
    Commit {
81
        #[arg(short, long)]
82
        message: String,
83
        /// Extra explicit dependencies (ChangeId prefix, #hash prefix)
84
        #[arg(long = "depends-on")]
85
        depends_on: Vec<String>,
86
        /// Commit only these paths; the rest stays as uncommitted work
87
        paths: Vec<String>,
88
        /// Choose hunks one by one
89
        #[arg(short, long)]
90
        interactive: bool,
91
        /// Commit these hunks (as `oxy hunks` numbers them), comma separated
92
        #[arg(long, value_delimiter = ',')]
93
        hunks: Vec<usize>,
94
    },
95
    /// Fold CHANGE into one of its dependencies (keeps that change's id)
96
    Squash {
97
        change: String,
98
        #[arg(long)]
99
        into: String,
100
    },
101
    /// Re-express CHANGE against another base state
102
    Rebase {
103
        change: String,
104
        /// The changes, bookmark or tag whose state becomes the new base
105
        #[arg(long, required = true, num_args = 1..)]
106
        onto: Vec<String>,
107
    },
108
    /// Show which change introduced each line of a file
109
    Blame {
110
        path: String,
111
        #[arg(long)]
112
        json: bool,
113
    },
114
    /// Find the change that introduced a regression
115
    Bisect {
116
        #[command(subcommand)]
117
        cmd: BisectCmd,
118
    },
119
    /// List changes reachable from the bookmark and the working copy
120
    Log {
121
        /// Show at most this many changes
122
        #[arg(short = 'n', long)]
123
        limit: Option<usize>,
124
        /// Show full messages, dependencies, and signatures
125
        #[arg(short, long)]
126
        verbose: bool,
127
        /// Only changes touching this path (renames followed)
128
        #[arg(long)]
129
        path: Option<String>,
130
        #[arg(long)]
131
        json: bool,
132
    },
133
    /// Show what the working copy changes against its base
134
    Diff {
135
        /// A change instead of the working copy
136
        change: Option<String>,
137
        #[arg(long)]
138
        json: bool,
139
    },
140
    /// Print a file as it is in a state (default: the working copy's base)
141
    Cat {
142
        path: String,
143
        /// A change, bookmark, or tag
144
        #[arg(short = 'r', long)]
145
        change: Option<String>,
146
    },
147
    /// Print the repository root, workspace, and bookmark
148
    Root {
149
        #[arg(long)]
150
        json: bool,
151
    },
152
    /// Print the version of oxy, its repository format, and protocol
153
    Version {
154
        #[arg(long)]
155
        json: bool,
156
    },
157
    /// Restore paths to the working copy's base, or undo chosen hunks
158
    Discard {
159
        paths: Vec<String>,
160
        /// Hunk indices as `oxy hunks` numbers them, comma separated
161
        #[arg(long, value_delimiter = ',')]
162
        hunks: Vec<usize>,
163
    },
164
    /// List the working copy's hunks, numbered as commit --hunks expects
165
    Hunks {
166
        #[arg(long)]
167
        json: bool,
168
    },
169
    /// Change the message of a head (default: the head the working copy sits on)
170
    Describe {
171
        #[arg(short, long)]
172
        message: String,
173
        change: Option<String>,
174
    },
175
    /// Fold the working copy into the head it sits on, or into CHANGE with --into
176
    Amend {
177
        #[arg(short, long)]
178
        message: Option<String>,
179
        /// Amend an older change; the edits must touch only lines it already knows
180
        #[arg(long)]
181
        into: Option<String>,
182
    },
183
    /// Split a head: the named paths become a separate first change
184
    Split { change: String, paths: Vec<String> },
185
    /// Drop a head from the bookmark; its content stays on disk as uncommitted work
186
    Abandon { change: String },
187
    /// Show one change (ChangeId prefix, #hash prefix, or @)
188
    Show {
189
        change: String,
190
        #[arg(long)]
191
        json: bool,
192
    },
193
    /// Move the working copy to the state formed by CHANGE... (default: the bookmark heads)
194
    Checkout {
195
        changes: Vec<String>,
196
        /// Throw away uncommitted working-copy changes
197
        #[arg(long)]
198
        discard: bool,
199
    },
200
    /// Report which conflicts of the working copy's base are resolved by the current files
201
    Resolve {
202
        #[arg(long)]
203
        json: bool,
204
    },
205
    /// Undo the last operation
206
    Undo,
207
    /// Write a checkpoint of the current bookmark's state now
208
    Checkpoint,
209
    /// Pack loose objects and prune unreachable ones older than the grace period
210
    Gc {
211
        /// Ignore the grace period (core.gc-grace) and prune immediately
212
        #[arg(long)]
213
        now: bool,
214
    },
215
    /// List operations
216
    #[command(name = "op")]
217
    Op {
218
        #[command(subcommand)]
219
        cmd: OpCmd,
220
    },
221
    /// Take the advisory local lock on a lockable file, making it writable
222
    Lock { path: String },
223
    /// Release the local lock and make the file read-only again
224
    Unlock { path: String },
225
    /// Workspaces: extra checkout directories sharing this repository
226
    Workspace {
227
        #[command(subcommand)]
228
        cmd: WorkspaceCmd,
229
    },
230
    /// Bookmarks: named states; each workspace works on one
231
    Bookmark {
232
        #[command(subcommand)]
233
        cmd: BookmarkCmd,
234
    },
235
    /// Union another bookmark's heads into the current one (no merge change)
236
    Merge { bookmark: String },
237
    /// Subrepositories: nested repositories pinned to a state
238
    Submodule {
239
        #[command(subcommand)]
240
        cmd: SubmoduleCmd,
241
    },
242
    /// Tags: immutable named states
243
    Tag {
244
        #[command(subcommand)]
245
        cmd: TagCmd,
246
    },
247
    /// Manage remotes
248
    Remote {
249
        #[command(subcommand)]
250
        cmd: RemoteCmd,
251
    },
252
    /// Fetch every bookmark of a remote into its tracking references
253
    Fetch {
254
        remote: Option<String>,
255
        #[arg(long)]
256
        json: bool,
257
    },
258
    /// Fetch, then union the remote bookmark into the local one (no merge change)
259
    Pull {
260
        remote: Option<String>,
261
        #[arg(long)]
262
        json: bool,
263
    },
264
    /// Push the current bookmark to a remote
265
    Push {
266
        remote: Option<String>,
267
        /// Allow dropping heads the remote has
268
        #[arg(long)]
269
        force: bool,
270
        /// Push this bookmark instead of the workspace's current one
271
        #[arg(short = 'b', long)]
272
        bookmark: Option<String>,
273
        #[arg(long)]
274
        json: bool,
275
    },
276
    /// Serve repositories under ROOT over HTTPS (with --tls-cert/--tls-key) or plain HTTP
277
    Serve {
278
        /// Directory with one repository per subdirectory
279
        #[arg(long, default_value = ".")]
280
        root: PathBuf,
281
        #[arg(long, default_value = "127.0.0.1:8890")]
282
        bind: String,
283
        /// Bearer token allowed to push (repeatable); none means open
284
        #[arg(long = "token")]
285
        tokens: Vec<String>,
286
        /// PEM certificate chain; enables HTTPS together with --tls-key
287
        #[arg(long, requires = "tls_key")]
288
        tls_cert: Option<PathBuf>,
289
        /// PEM private key
290
        #[arg(long, requires = "tls_cert")]
291
        tls_key: Option<PathBuf>,
292
    },
293
    /// Manage the signing identity
294
    Identity {
295
        #[command(subcommand)]
296
        cmd: IdentityCmd,
297
    },
298
    /// Verify the signatures on a change (default: every change in the log)
299
    Verify {
300
        change: Option<String>,
301
        #[arg(long)]
302
        json: bool,
303
    },
304
    /// Git interoperability
305
    Git {
306
        #[command(subcommand)]
307
        cmd: GitCmd,
308
    },
309
    /// Manage the trust policy (who may update which bookmarks)
310
    Policy {
311
        #[command(subcommand)]
312
        cmd: PolicyCmd,
313
    },
314
    /// 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)
315
    Config {
316
        key: String,
317
        value: String,
318
        /// Write to the user file (~/.config/oxy/config.toml) instead of this repository
319
        #[arg(long)]
320
        user: bool,
321
    },
322
}
323
324
#[derive(Subcommand)]
325
enum OpCmd {
326
    Log {
327
        #[arg(long)]
328
        json: bool,
329
    },
330
}
331
332
#[derive(Subcommand)]
333
enum WorkspaceCmd {
334
    /// Create a workspace at PATH checked out on CHANGE... (default: the bookmark heads)
335
    Add { path: PathBuf, changes: Vec<String> },
336
    List {
337
        #[arg(long)]
338
        json: bool,
339
    },
340
    /// Stop tracking a workspace (by id prefix or path); its files stay
341
    Forget { workspace: String },
342
}
343
344
#[derive(Subcommand)]
345
enum BisectCmd {
346
    /// Begin; remembers where the working copy was
347
    Start,
348
    /// Mark CHANGE... (or the state under test) as good
349
    Good { changes: Vec<String> },
350
    /// Mark CHANGE... (or the state under test) as bad
351
    Bad { changes: Vec<String> },
352
    /// The state under test cannot be tested; try another
353
    Skip,
354
    /// Run a command for each step: exit 0 good, 125 skip, else bad
355
    Run {
356
        #[arg(required = true, trailing_var_arg = true)]
357
        command: Vec<String>,
358
    },
359
    /// Where the search stands
360
    Status {
361
        #[arg(long)]
362
        json: bool,
363
    },
364
    /// Restore the working copy and forget the search
365
    Reset,
366
}
367
368
#[derive(Subcommand)]
369
enum BookmarkCmd {
370
    /// Create a bookmark at CHANGE... (default: the working copy's base)
371
    Create { name: String, changes: Vec<String> },
372
    /// Point an existing bookmark at CHANGE...
373
    Set { name: String, changes: Vec<String> },
374
    /// Remove a bookmark; its changes stay
375
    Delete { name: String },
376
    /// List bookmarks with their heads and difference from origin
377
    List {
378
        #[arg(long)]
379
        json: bool,
380
    },
381
    /// Make NAME this workspace's bookmark and check it out
382
    Switch {
383
        name: String,
384
        /// Throw away uncommitted working-copy changes
385
        #[arg(long)]
386
        discard: bool,
387
    },
388
}
389
390
#[derive(Subcommand)]
391
enum SubmoduleCmd {
392
    /// Clone URL (Oxygen or Git) into PATH and register it in .oxymodules
393
    Add {
394
        url: String,
395
        path: String,
396
        /// Bookmark (Oxygen) or branch (Git) to check out and track
397
        #[arg(long)]
398
        bookmark: Option<String>,
399
    },
400
    /// Bring nested repositories to their pins
401
    Update {
402
        /// Clone nested repositories that are absent
403
        #[arg(long)]
404
        init: bool,
405
        paths: Vec<String>,
406
    },
407
    /// List subrepos with their pins and on-disk state
408
    Status {
409
        #[arg(long)]
410
        json: bool,
411
    },
412
    /// Unregister PATH; the directory stays, the node goes with the next commit
413
    Remove { path: String },
414
}
415
416
#[derive(Subcommand)]
417
enum TagCmd {
418
    /// Tag the state of CHANGE... (default: the bookmark heads)
419
    Create {
420
        name: String,
421
        changes: Vec<String>,
422
        #[arg(short, long, default_value = "")]
423
        message: String,
424
    },
425
    List {
426
        #[arg(long)]
427
        json: bool,
428
    },
429
}
430
431
#[derive(Subcommand)]
432
enum RemoteCmd {
433
    Add {
434
        name: String,
435
        url: String,
436
    },
437
    Remove {
438
        name: String,
439
    },
440
    List {
441
        #[arg(long)]
442
        json: bool,
443
    },
444
}
445
446
#[derive(Subcommand)]
447
enum IdentityCmd {
448
    /// Generate a composite Ed25519 + ML-DSA-65 key pair and make it your author identity
449
    Create {
450
        #[arg(long)]
451
        name: Option<String>,
452
        #[arg(long)]
453
        email: Option<String>,
454
        /// Record the author in this repository only, not in the user config
455
        #[arg(long)]
456
        local: bool,
457
        /// Expire the identity this many days from now
458
        #[arg(long)]
459
        expires: Option<u64>,
460
    },
461
    /// Show the configured identity
462
    Show,
463
    /// Write your identity object to a file, to hand to a policy holder
464
    Export { path: Option<PathBuf> },
465
    /// Move to a fresh key pair; the policy follows if it names your key
466
    Rotate,
467
    /// Re-issue your identity with a new expiry (in days from now; 0 = never)
468
    Renew {
469
        #[arg(long)]
470
        expires: u64,
471
    },
472
    /// Revoke a key: yours by default, or any key if you hold a policy root
473
    Revoke {
474
        /// KeyId prefix (default: your own key)
475
        key: Option<String>,
476
        #[arg(long, default_value = "")]
477
        reason: String,
478
    },
479
    /// Keys allowed to sign or seal on your behalf
480
    Delegate {
481
        #[command(subcommand)]
482
        cmd: DelegateCmd,
483
    },
484
}
485
486
#[derive(Subcommand)]
487
enum DelegateCmd {
488
    /// Add a delegate from an exported identity file
489
    Add { identity_file: PathBuf },
490
    /// Remove a delegate by KeyId prefix
491
    Remove { key: String },
492
    /// List delegates
493
    List,
494
}
495
496
#[derive(Subcommand)]
497
enum GitCmd {
498
    /// Export the current bookmark to a Git repository (created bare if absent)
499
    Export {
500
        git_dir: PathBuf,
501
        /// Git branch to write (default: the bookmark name)
502
        #[arg(long)]
503
        branch: Option<String>,
504
    },
505
    /// Fetch a branch from a Git remote (path or URL) into the current bookmark
506
    Fetch {
507
        url: String,
508
        #[arg(long, default_value = "main")]
509
        branch: String,
510
    },
511
    /// Push the current bookmark to a branch of a Git remote (fetch first)
512
    Push {
513
        url: String,
514
        #[arg(long, default_value = "main")]
515
        branch: String,
516
    },
517
    /// Import a Git branch into a new Oxygen repository at DEST
518
    Import {
519
        git_dir: PathBuf,
520
        dest: PathBuf,
521
        #[arg(long, default_value = "main")]
522
        branch: String,
523
    },
524
}
525
526
#[derive(Subcommand)]
527
enum PolicyCmd {
528
    /// Create the initial policy with your identity as the only root
529
    Init,
530
    /// Show the current policy
531
    Show {
532
        #[arg(long)]
533
        json: bool,
534
    },
535
    /// Allow an identity (from `oxy identity export`) to update bookmarks
536
    Grant {
537
        identity_file: PathBuf,
538
        /// Reference pattern the grant applies to (default: every bookmark)
539
        #[arg(long)]
540
        pattern: Option<String>,
541
        /// Where to write the proposal when more root signatures are needed
542
        #[arg(long)]
543
        out: Option<PathBuf>,
544
    },
545
    /// Revoke a key (KeyId prefix of an identity in the policy)
546
    Revoke {
547
        key: String,
548
        /// Where to write the proposal when more root signatures are needed
549
        #[arg(long)]
550
        out: Option<PathBuf>,
551
    },
552
    /// Manage root keys and the signature threshold for policy updates
553
    Root {
554
        #[command(subcommand)]
555
        cmd: RootCmd,
556
    },
557
    /// Add your root signature to a proposal file; applies it once the threshold is met
558
    Sign {
559
        proposal: PathBuf,
560
        /// Where to write the proposal if it still needs signatures (default: in place)
561
        #[arg(long)]
562
        out: Option<PathBuf>,
563
    },
564
}
565
566
#[derive(Subcommand)]
567
enum RootCmd {
568
    /// Make an exported identity a root key
569
    Add {
570
        identity_file: PathBuf,
571
        #[arg(long)]
572
        out: Option<PathBuf>,
573
    },
574
    /// Remove a root key by KeyId prefix
575
    Remove {
576
        key: String,
577
        #[arg(long)]
578
        out: Option<PathBuf>,
579
    },
580
    /// Require this many root signatures on policy updates
581
    Threshold {
582
        n: u32,
583
        #[arg(long)]
584
        out: Option<PathBuf>,
585
    },
586
}
587
588
/// Open the repository containing the current directory.
589
fn open() -> Result<Repo> {
590
    Repo::open(&std::env::current_dir()?).context("opening repository")
591
}
592
593
/// Parse arguments and run; returns the process exit code.
594
pub fn run() -> Result<i32> {
595
    let cli = Cli::parse();
596
    ui::init(cli.plain);
597
    match cli.cmd {
598
        Cmd::Init { path, bare } => workspace::init(path, bare),
599
        Cmd::Status { json } => workspace::status(json),
600
        Cmd::Prompt {
601
            format,
602
            glyphs,
603
            color,
604
        } => workspace::prompt(&format, glyphs, color.as_deref()),
605
        Cmd::Commit {
606
            message,
607
            depends_on,
608
            paths,
609
            interactive,
610
            hunks,
611
        } => workspace::commit(&message, &depends_on, &paths, interactive, &hunks),
612
        Cmd::Cat { path, change } => workspace::cat(&path, change.as_deref()),
613
        Cmd::Root { json } => workspace::root(json),
614
        Cmd::Version { json } => workspace::version(json),
615
        Cmd::Discard { paths, hunks } => workspace::discard(&paths, &hunks),
616
        Cmd::Hunks { json } => workspace::hunks(json),
617
        Cmd::Squash { change, into } => workspace::squash(&change, &into),
618
        Cmd::Rebase { change, onto } => workspace::rebase(&change, &onto),
619
        Cmd::Blame { path, json } => workspace::blame(&path, json),
620
        Cmd::Bisect { cmd } => match cmd {
621
            BisectCmd::Start => workspace::bisect_start(),
622
            BisectCmd::Good { changes } => workspace::bisect_mark(Some(true), &changes),
623
            BisectCmd::Bad { changes } => workspace::bisect_mark(Some(false), &changes),
624
            BisectCmd::Skip => workspace::bisect_mark(None, &[]),
625
            BisectCmd::Run { command } => workspace::bisect_run(&command),
626
            BisectCmd::Status { json } => workspace::bisect_status(json),
627
            BisectCmd::Reset => workspace::bisect_reset(),
628
        },
629
        Cmd::Log {
630
            limit,
631
            verbose,
632
            path,
633
            json,
634
        } => workspace::log(limit, verbose, path.as_deref(), json),
635
        Cmd::Diff { change, json } => workspace::diff(change.as_deref(), json),
636
        Cmd::Describe { message, change } => workspace::describe(&message, change.as_deref()),
637
        Cmd::Amend { message, into } => workspace::amend(message.as_deref(), into.as_deref()),
638
        Cmd::Split { change, paths } => workspace::split(&change, &paths),
639
        Cmd::Abandon { change } => workspace::abandon(&change),
640
        Cmd::Show { change, json } => workspace::show(&change, json),
641
        Cmd::Checkout { changes, discard } => workspace::checkout(&changes, discard),
642
        Cmd::Resolve { json } => workspace::resolve(json),
643
        Cmd::Undo => workspace::undo(),
644
        Cmd::Gc { now } => workspace::gc(now),
645
        Cmd::Checkpoint => workspace::checkpoint(),
646
        Cmd::Op {
647
            cmd: OpCmd::Log { json },
648
        } => workspace::op_log(json),
649
        Cmd::Clone {
650
            url,
651
            dest,
652
            max_blob,
653
            sparse,
654
            depth,
655
        } => sync::clone(&url, dest, max_blob.as_deref(), &sparse, depth),
656
        Cmd::Deepen { depth, remote } => sync::deepen(&remote, depth),
657
        Cmd::Sparse { paths } => workspace::sparse(&paths),
658
        Cmd::Lock { path } => workspace::lock(&path),
659
        Cmd::Unlock { path } => workspace::unlock(&path),
660
        Cmd::Workspace { cmd } => match cmd {
661
            WorkspaceCmd::Add { path, changes } => workspace::workspace_add(&path, &changes),
662
            WorkspaceCmd::List { json } => workspace::workspace_list(json),
663
            WorkspaceCmd::Forget { workspace } => workspace::workspace_forget(&workspace),
664
        },
665
        Cmd::Bookmark { cmd } => match cmd {
666
            BookmarkCmd::Create { name, changes } => workspace::bookmark_create(&name, &changes),
667
            BookmarkCmd::Set { name, changes } => workspace::bookmark_set(&name, &changes),
668
            BookmarkCmd::Delete { name } => workspace::bookmark_delete(&name),
669
            BookmarkCmd::List { json } => workspace::bookmark_list(json),
670
            BookmarkCmd::Switch { name, discard } => workspace::bookmark_switch(&name, discard),
671
        },
672
        Cmd::Merge { bookmark } => workspace::merge(&bookmark),
673
        Cmd::Submodule { cmd } => match cmd {
674
            SubmoduleCmd::Add {
675
                url,
676
                path,
677
                bookmark,
678
            } => sync::submodule_add(&url, &path, bookmark.as_deref()),
679
            SubmoduleCmd::Update { init, paths } => sync::submodule_update(init, &paths),
680
            SubmoduleCmd::Status { json } => sync::submodule_status(json),
681
            SubmoduleCmd::Remove { path } => sync::submodule_remove(&path),
682
        },
683
        Cmd::Tag { cmd } => match cmd {
684
            TagCmd::Create {
685
                name,
686
                changes,
687
                message,
688
            } => workspace::tag_create(&name, &changes, &message),
689
            TagCmd::List { json } => workspace::tag_list(json),
690
        },
691
        Cmd::Remote { cmd } => match cmd {
692
            RemoteCmd::Add { name, url } => sync::remote_add(&name, &url),
693
            RemoteCmd::Remove { name } => sync::remote_remove(&name),
694
            RemoteCmd::List { json } => sync::remote_list(json),
695
        },
696
        Cmd::Fetch { remote, json } => sync::fetch(remote.as_deref(), json),
697
        Cmd::Pull { remote, json } => sync::pull(remote.as_deref(), json),
698
        Cmd::Push {
699
            remote,
700
            force,
701
            bookmark,
702
            json,
703
        } => sync::push(remote.as_deref(), force, bookmark.as_deref(), json),
704
        Cmd::Serve {
705
            root,
706
            bind,
707
            tokens,
708
            tls_cert,
709
            tls_key,
710
        } => sync::serve(root, &bind, tokens, tls_cert.zip(tls_key)),
711
        Cmd::Identity { cmd } => match cmd {
712
            IdentityCmd::Create {
713
                name,
714
                email,
715
                local,
716
                expires,
717
            } => identity::create(name, email, local, expires),
718
            IdentityCmd::Show => identity::show(),
719
            IdentityCmd::Export { path } => identity::export(path),
720
            IdentityCmd::Rotate => identity::rotate(),
721
            IdentityCmd::Renew { expires } => identity::renew(expires),
722
            IdentityCmd::Revoke { key, reason } => identity::revoke(key.as_deref(), &reason),
723
            IdentityCmd::Delegate { cmd } => match cmd {
724
                DelegateCmd::Add { identity_file } => identity::delegate_add(&identity_file),
725
                DelegateCmd::Remove { key } => identity::delegate_remove(&key),
726
                DelegateCmd::List => identity::delegate_list(),
727
            },
728
        },
729
        Cmd::Git {
730
            cmd: GitCmd::Export { git_dir, branch },
731
        } => sync::git_export(&git_dir, branch.as_deref()),
732
        Cmd::Git {
733
            cmd: GitCmd::Fetch { url, branch },
734
        } => sync::git_fetch(&url, &branch),
735
        Cmd::Git {
736
            cmd: GitCmd::Push { url, branch },
737
        } => sync::git_push(&url, &branch),
738
        Cmd::Git {
739
            cmd:
740
                GitCmd::Import {
741
                    git_dir,
742
                    dest,
743
                    branch,
744
                },
745
        } => sync::git_import(&git_dir, &dest, &branch),
746
        Cmd::Policy { cmd } => match cmd {
747
            PolicyCmd::Init => identity::policy_init(),
748
            PolicyCmd::Show { json } => identity::policy_show(json),
749
            PolicyCmd::Grant {
750
                identity_file,
751
                pattern,
752
                out,
753
            } => identity::policy_grant(&identity_file, pattern.as_deref(), out),
754
            PolicyCmd::Revoke { key, out } => identity::policy_revoke(&key, out),
755
            PolicyCmd::Root { cmd } => match cmd {
756
                RootCmd::Add { identity_file, out } => {
757
                    identity::policy_root_add(&identity_file, out)
758
                }
759
                RootCmd::Remove { key, out } => identity::policy_root_remove(&key, out),
760
                RootCmd::Threshold { n, out } => identity::policy_threshold(n, out),
761
            },
762
            PolicyCmd::Sign { proposal, out } => identity::policy_sign(&proposal, out),
763
        },
764
        Cmd::Verify { change, json } => identity::verify(change.as_deref(), json),
765
        Cmd::Config { key, value, user } => identity::config(&key, &value, user),
766
    }
767
}