delete added, more details below (#3)

- readme updates
- delete command added
- commands now saved in a map vs fields
- login and run now ensure config has been run to prevent errors

Reviewed-on: #3
Co-authored-by: jake <jake.young.dev@gmail.com>
Co-committed-by: jake <jake.young.dev@gmail.com>
This commit is contained in:
2025-04-17 21:25:54 +00:00
committed by jake
parent a9c6400761
commit f8a9528e0f
8 changed files with 121 additions and 17 deletions

View File

@@ -5,6 +5,7 @@ package cmd
import (
"bufio"
"errors"
"fmt"
"os"
@@ -15,9 +16,10 @@ import (
// loginCmd represents the login command
var loginCmd = &cobra.Command{
Use: "login",
Example: "mctl login",
Short: "Login to server and send commands",
Use: "login",
Example: "mctl login",
SilenceUsage: true,
Short: "Login to server and send commands",
Long: `Login to server using saved config and enter command loop
sending commands to server and printing the response.`,
Run: func(cmd *cobra.Command, args []string) {
@@ -54,6 +56,13 @@ var loginCmd = &cobra.Command{
fmt.Printf("Disconnected from %s\n", server)
},
PreRunE: func(cmd *cobra.Command, args []string) error {
//ensure config command has been run
if viper.Get("server") == "" || viper.Get("password") == "" || viper.Get("port") == 0 {
return errors.New("the 'config' command must be run before you can interact with servers")
}
return nil
},
}
func init() {