@@ -27,6 +27,7 @@ import (
2727 "github.com/schollz/pake/v3"
2828 "github.com/schollz/peerdiscovery"
2929 "github.com/schollz/progressbar/v3"
30+ "github.com/skip2/go-qrcode"
3031 "golang.org/x/term"
3132 "golang.org/x/time/rate"
3233
@@ -85,6 +86,7 @@ type Options struct {
8586 TestFlag bool
8687 GitIgnore bool
8788 MulticastAddress string
89+ ShowQrCode bool
8890}
8991
9092type SimpleMessage struct {
@@ -660,6 +662,9 @@ On the other computer run:
660662 CROC_SECRET=%[1]q croc %[2]s
661663` , c .Options .SharedSecret , flags .String ())
662664 copyToClipboard (c .Options .SharedSecret )
665+ if c .Options .ShowQrCode {
666+ showReceiveCommandQrCode (fmt .Sprintf ("%[1]s" , c .Options .SharedSecret ))
667+ }
663668 if c .Options .Ask {
664669 machid , _ := machineid .ID ()
665670 fmt .Fprintf (os .Stderr , "\r Your machine ID is '%s'\n " , machid )
@@ -832,6 +837,13 @@ On the other computer run:
832837 return err
833838}
834839
840+ func showReceiveCommandQrCode (command string ) {
841+ qrCode , err := qrcode .New (command , qrcode .Medium )
842+ if err == nil {
843+ fmt .Println (qrCode .ToSmallString (false ))
844+ }
845+ }
846+
835847// Receive will receive a file
836848func (c * Client ) Receive () (err error ) {
837849 fmt .Fprintf (os .Stderr , "connecting..." )
@@ -2146,5 +2158,5 @@ func copyToClipboard(str string) {
21462158 log .Debugf ("error copying to clipboard: %v" , err )
21472159 return
21482160 }
2149- fmt .Fprintf (os .Stderr , "Code copied to clipboard" )
2161+ fmt .Fprintf (os .Stderr , "Code copied to clipboard\n " )
21502162}
0 commit comments