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