mirror of
https://github.com/cmz0228/hysteria-dev.git
synced 2025-06-08 13:29:53 +00:00
chore: move print QR func to utils
This commit is contained in:
parent
e21e5c67a8
commit
6aa60e12d1
@ -10,7 +10,6 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/mdp/qrterminal/v3"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"go.uber.org/zap"
|
||||
@ -264,12 +263,7 @@ func runClient(cmd *cobra.Command, args []string) {
|
||||
uri := config.ShareURI()
|
||||
logger.Info("use this URI to share your server", zap.String("uri", uri))
|
||||
if showQR {
|
||||
qrterminal.GenerateWithConfig(uri, qrterminal.Config{
|
||||
Level: qrterminal.L,
|
||||
Writer: os.Stdout,
|
||||
BlackChar: qrterminal.BLACK,
|
||||
WhiteChar: qrterminal.WHITE,
|
||||
})
|
||||
printQR(uri)
|
||||
}
|
||||
|
||||
// Modes
|
||||
|
@ -2,8 +2,10 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/apernet/hysteria/extras/utils"
|
||||
"github.com/mdp/qrterminal/v3"
|
||||
)
|
||||
|
||||
// convBandwidth handles both string and int types for bandwidth.
|
||||
@ -21,6 +23,15 @@ func convBandwidth(bw interface{}) (uint64, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func printQR(str string) {
|
||||
qrterminal.GenerateWithConfig(str, qrterminal.Config{
|
||||
Level: qrterminal.L,
|
||||
Writer: os.Stdout,
|
||||
BlackChar: qrterminal.BLACK,
|
||||
WhiteChar: qrterminal.WHITE,
|
||||
})
|
||||
}
|
||||
|
||||
type configError struct {
|
||||
Field string
|
||||
Err error
|
||||
|
Loading…
x
Reference in New Issue
Block a user