diff options
author | Slack Coder <slackcoder@server.ky> | 2022-05-17 11:00:28 -0500 |
---|---|---|
committer | Slack Coder <slackcoder@server.ky> | 2022-05-17 11:00:28 -0500 |
commit | 6c0acbc7c9f7418965c138d3b101e6d1e8f77ede (patch) | |
tree | 923f5ce38c36eae0f8f7c96cf0fe330eb0539222 /qr_code.go | |
download | send-over-http-6c0acbc7c9f7418965c138d3b101e6d1e8f77ede.tar.xz |
initial commit
Diffstat (limited to 'qr_code.go')
-rw-r--r-- | qr_code.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/qr_code.go b/qr_code.go new file mode 100644 index 0000000..13a4aa0 --- /dev/null +++ b/qr_code.go @@ -0,0 +1,39 @@ +package sendoverhttp + +import ( + "fmt" + "os" + + "github.com/mdp/qrterminal/v3" + _ "github.com/mdp/qrterminal/v3" +) + +type TerminalQRShower struct { + waiter *Waiter + str string +} + +func NewTerminalQRShower(str string) *TerminalQRShower { + return &TerminalQRShower{ + waiter: NewWaiter(), + str: str, + } +} + +// Start the run, returning any error which occurs from start to +// finish. +func (s *TerminalQRShower) Start() error { + qrterminal.Generate(s.str, qrterminal.L, os.Stdout) + fmt.Println() + fmt.Printf("serving on '%s'", s.str) + fmt.Println() + fmt.Println() + s.waiter.Wait() + return nil +} + +// Stop the run and wait until it has ended. It can be called multiple +// times, ending immediately. +func (s *TerminalQRShower) Stop() { + s.waiter.Stop() +} |