diff --git a/client/mcr.go b/client/mcr.go index 4ddd754..f0f7ea8 100644 --- a/client/mcr.go +++ b/client/mcr.go @@ -14,7 +14,7 @@ import ( */ type Client struct { - cli *mcr.Client + cli mcr.Client } type IClient interface { @@ -25,9 +25,9 @@ type IClient interface { // creates a new mcr client using saved credentials and decrypted password func New() (*Client, error) { //grab saved credentials - server := viper.Get("server").(string) - password := viper.Get("password").(string) - port := viper.Get("port").(int) + server := viper.GetString("server") + password := viper.GetString("password") + port := viper.GetInt("port") fmt.Printf("Logging into %s on port %d\n", server, port) //decrypt password diff --git a/cmd/login.go b/cmd/login.go index 84e22f9..d8cabfc 100644 --- a/cmd/login.go +++ b/cmd/login.go @@ -24,7 +24,7 @@ var loginCmd = &cobra.Command{ sending commands to server and printing the response.`, Run: func(cmd *cobra.Command, args []string) { //grab saved credentials - server := viper.Get("server").(string) + server := viper.GetString("server") cli, err := client.New() cobra.CheckErr(err) defer cli.Close() diff --git a/cryptography/aes.go b/cryptography/aes.go index d5f8012..281a000 100644 --- a/cryptography/aes.go +++ b/cryptography/aes.go @@ -8,8 +8,8 @@ import ( ) func EncryptPassword(b []byte) ([]byte, error) { - nonce := viper.Get("nonce").(string) - dev := viper.Get("device").(string) + nonce := viper.GetString("nonce") + dev := viper.GetString("device") block, err := aes.NewCipher([]byte(dev)) if err != nil { @@ -29,9 +29,9 @@ func EncryptPassword(b []byte) ([]byte, error) { } func DecryptPassword(b []byte) (string, error) { - nonce := viper.Get("nonce").(string) - password := viper.Get("password").(string) - dev := viper.Get("device").(string) + nonce := viper.GetString("nonce") + password := viper.GetString("password") + dev := viper.GetString("device") block, err := aes.NewCipher([]byte(dev)) if err != nil { diff --git a/go.mod b/go.mod index d1e9163..8dd253a 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module code.jakeyoungdev.com/jake/mctl go 1.24.2 require ( - github.com/jake-young-dev/mcr v1.3.1 + github.com/jake-young-dev/mcr v1.3.3-0.20250531035550-4d1e822a867f github.com/spf13/cobra v1.9.1 github.com/spf13/viper v1.20.1 golang.org/x/term v0.31.0 diff --git a/go.sum b/go.sum index a84a88c..c5a26c3 100644 --- a/go.sum +++ b/go.sum @@ -14,6 +14,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jake-young-dev/mcr v1.3.1 h1:ELJsrJHwQsMiM09o+q8auUaiGXXX3DWIgh/TfZQc0B0= github.com/jake-young-dev/mcr v1.3.1/go.mod h1:74yZHGf9h3tLUDUpInA17grKLrNp9lVesWvisCFCXKY= +github.com/jake-young-dev/mcr v1.3.3-0.20250531035550-4d1e822a867f h1:G0G+K+dtO63jByfA7XDxvP8dCTET5C+CRbJjFCysXwM= +github.com/jake-young-dev/mcr v1.3.3-0.20250531035550-4d1e822a867f/go.mod h1:74yZHGf9h3tLUDUpInA17grKLrNp9lVesWvisCFCXKY= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=