mirror of
https://github.com/fiatjaf/nak.git
synced 2025-12-09 17:18:50 +00:00
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:
committed by
fiatjaf_
parent
fea23aecc3
commit
d32654447a
12
bunker.go
12
bunker.go
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user