Skip to content

Commit d6e0f36

Browse files
authored
Merge pull request #48 from auths-dev/feature/top-level-pair-command
feat: add `auths pair` as a top-level command
2 parents e5168b2 + f819df4 commit d6e0f36

8 files changed

Lines changed: 53 additions & 2 deletions

File tree

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ repos:
3535
types: [rust]
3636
pass_filenames: false
3737

38+
- id: gen-docs-check
39+
name: cargo xtask gen-docs --check
40+
entry: cargo xtask gen-docs --check
41+
language: system
42+
files: (crates/auths-cli/src/|crates/xtask/src/gen_docs|docs/cli/commands/)
43+
pass_filenames: false
44+
3845
- id: cargo-deny
3946
name: cargo deny (licenses + bans)
4047
entry: bash -c 'cargo deny check > .cargo/cargo-deny.log 2>&1; exit $?'

crates/auths-cli/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ auths verify HEAD
1313

1414
That's it. `auths init` generates keys, creates your identity, and configures Git signing.
1515

16+
### Link another device
17+
18+
```bash
19+
auths pair # On existing device — shows QR/code
20+
auths pair --join ABC123 # On new device — enter the code
21+
```
22+
1623
## The Basics
1724

1825
### `auths sign` — Sign a commit or artifact

crates/auths-cli/src/cli.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use crate::commands::completions::CompletionsCommand;
1212
use crate::commands::config::ConfigCommand;
1313
use crate::commands::debug::DebugCmd;
1414
use crate::commands::device::DeviceCommand;
15+
use crate::commands::device::pair::PairCommand;
1516
use crate::commands::doctor::DoctorCommand;
1617
use crate::commands::emergency::EmergencyCommand;
1718
use crate::commands::git::GitCommand;
@@ -91,6 +92,7 @@ pub enum RootCommand {
9192
Whoami(WhoamiCommand),
9293
Tutorial(LearnCommand),
9394
Doctor(DoctorCommand),
95+
Pair(PairCommand),
9496
#[command(hide = true)]
9597
Completions(CompletionsCommand),
9698
#[command(hide = true)]

crates/auths-cli/src/commands/device/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ use crate::commands::executable::ExecutableCommand;
1010
use crate::config::CliConfig;
1111
use anyhow::Result;
1212

13+
impl ExecutableCommand for PairCommand {
14+
fn execute(&self, ctx: &CliConfig) -> Result<()> {
15+
handle_pair(self.clone(), &ctx.env_config)
16+
}
17+
}
18+
1319
impl ExecutableCommand for DeviceCommand {
1420
fn execute(&self, ctx: &CliConfig) -> Result<()> {
1521
handle_device(

crates/auths-cli/src/commands/learn.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,11 +476,11 @@ fn section_linking_device() -> Result<()> {
476476
println!(" To link a new device:");
477477
println!();
478478
println!(" {} On your existing device:", "1.".cyan());
479-
println!(" {}", "$ auths pair start".cyan());
479+
println!(" {}", "$ auths pair".cyan());
480480
println!(" {}", "Scan this QR code or enter: ABC123".dimmed());
481481
println!();
482482
println!(" {} On your new device:", "2.".cyan());
483-
println!(" {}", "$ auths pair join --code ABC123".cyan());
483+
println!(" {}", "$ auths pair --join ABC123".cyan());
484484
println!();
485485
println!(
486486
" This creates an {} that authorizes the new device",

crates/auths-cli/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ fn run() -> Result<()> {
6868
RootCommand::Whoami(cmd) => cmd.execute(&ctx),
6969
RootCommand::Tutorial(cmd) => cmd.execute(&ctx),
7070
RootCommand::Doctor(cmd) => cmd.execute(&ctx),
71+
RootCommand::Pair(cmd) => cmd.execute(&ctx),
7172
RootCommand::Completions(cmd) => cmd.execute(&ctx),
7273
RootCommand::Emergency(cmd) => cmd.execute(&ctx),
7374
RootCommand::Id(cmd) => cmd.execute(&ctx),

crates/xtask/src/gen_docs.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ const COMMANDS: &[Cmd] = &[
2929
marker: "auths status",
3030
doc_file: "docs/cli/commands/primary.md",
3131
},
32+
Cmd {
33+
args: &["pair"],
34+
marker: "auths pair",
35+
doc_file: "docs/cli/commands/primary.md",
36+
},
3237
// --- device ---
3338
Cmd {
3439
args: &["device", "link"],

docs/cli/commands/primary.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,26 @@ auths status
6262
| `-q, --quiet` || Suppress non-essential output |
6363
| `--repo <REPO>` || Override the local storage directory (default: ~/.auths) |
6464
<!-- END GENERATED: auths status -->
65+
66+
---
67+
68+
## auths pair
69+
70+
```bash
71+
auths pair
72+
```
73+
74+
<!-- BEGIN GENERATED: auths pair -->
75+
| Flag | Default | Description |
76+
|------|---------|-------------|
77+
| `--join <CODE>` || |
78+
| `--registry <URL>` || |
79+
| `--no-qr` || |
80+
| `--timeout <SECONDS>` || |
81+
| `--offline` || |
82+
| `--capabilities <CAPABILITIES>` || |
83+
| `--no-mdns` || |
84+
| `--json` || |
85+
| `-q, --quiet` || |
86+
| `--repo <REPO>` || |
87+
<!-- END GENERATED: auths pair -->

0 commit comments

Comments
 (0)