blob: f21d01f0c38b83796fd4bb33419b91659a4bf607 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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("Hosting file at %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()
}
|