feat(bunker): add QR code generation for bunker URI

- Add `--qrcode` flag to display a QR code for the bunker URI.
- Update `README.md` with usage instructions for the new flag.
- Include `qrterminal` dependency for QR code generation.
This commit is contained in:
Anthony Accioly
2025-07-03 23:14:00 +01:00
committed by fiatjaf_
parent fea23aecc3
commit d32654447a
4 changed files with 30 additions and 12 deletions

View File

@@ -17,6 +17,7 @@ import (
"fiatjaf.com/nostr/nip19"
"fiatjaf.com/nostr/nip46"
"github.com/fatih/color"
"github.com/mdp/qrterminal/v3"
"github.com/urfave/cli/v3"
)
@@ -65,6 +66,10 @@ var bunker = &cli.Command{
Usage: "relays to connect to (can also be provided as naked arguments)",
Hidden: true,
},
&cli.BoolFlag{
Name: "qrcode",
Usage: "display a QR code for the bunker URI",
},
},
Action: func(ctx context.Context, c *cli.Command) error {
// read config from file
@@ -293,6 +298,13 @@ var bunker = &cli.Command{
colors.bold(bunkerURI),
)
}
// Print QR code if requested
if c.Bool("qrcode") {
log("QR Code for bunker URI:\n")
qrterminal.Generate(bunkerURI, qrterminal.L, os.Stdout)
log("\n\n")
}
}
printBunkerInfo()