chore: move print QR func to utils

This commit is contained in:
tobyxdd 2023-07-14 15:44:37 -07:00
parent e21e5c67a8
commit 6aa60e12d1
2 changed files with 12 additions and 7 deletions

View File

@ -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

View File

@ -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