Add QR code support for Device IDs

- Add printQR() helper function using qrencode
- Display QR code in sync setup for easy mobile pairing
- Add qrencode to doctor dependency check

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-16 22:28:10 -05:00
parent d3d720b3bc
commit dedfbfce64

View File

@@ -162,6 +162,18 @@ fn printCmd(cmd: String): Unit with {Process} = {
()
}
// Print a QR code for easy scanning (e.g., device IDs)
fn printQR(data: String): Unit with {Process} = {
if hasCommand("qrencode") then {
// Generate small terminal QR code and redirect to stderr
let ignore = Process.exec("qrencode -t ANSIUTF8 -m 1 '" + data + "' -o - >&2")
()
} else {
// Fallback: just show the data
printHint("(Install qrencode for QR codes)")
}
}
// =============================================================================
// Shell helpers
// =============================================================================
@@ -504,7 +516,9 @@ fn doSyncSetup(): Unit with {Process} = {
printBold("Your Device ID")
let ignore = Process.exec("printf '\\033[33m%s\\033[0m\\n' \"" + deviceId + "\" >&2")
print("")
printHint("Share this ID with other devices to pair.")
printQR(deviceId)
print("")
printHint("Scan the QR code or share this ID to pair devices.")
logEvent("sync", "Device ID displayed")
} else {
printStepWarn("Getting device ID", "retry in a moment")
@@ -981,6 +995,12 @@ fn showDoctor(): Unit with {Process} = {
printStepErr("age", "not found")
}
if hasCommand("qrencode") then {
printStep("qrencode", "installed")
} else {
printStepWarn("qrencode", "not found (QR codes disabled)")
}
// Directory check
print("")
let ignore2 = Process.exec("printf '\\033[2mDirectories:\\033[0m\\n' >&2")