- added 'command' subcommand - removed viper - setup commands added - still a WIP - readme TODO update
38 lines
705 B
Go
38 lines
705 B
Go
/*
|
|
Copyright © 2025 Jake jake.young.dev@gmail.com
|
|
*/
|
|
package server
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"code.jakeyoungdev.com/jake/mctl/database"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var viewCmd = &cobra.Command{
|
|
Use: "view",
|
|
Example: "mctl server view",
|
|
Short: "view all servers",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
db, err := database.New()
|
|
cobra.CheckErr(err)
|
|
defer db.Close()
|
|
|
|
ts, err := db.GetAllServers()
|
|
cobra.CheckErr(err)
|
|
|
|
for _, s := range ts {
|
|
fmt.Println("-----")
|
|
fmt.Printf("Name: %s\n", s.Name)
|
|
fmt.Printf("Address: %s\n", s.Server)
|
|
fmt.Printf("Port: %d\n", s.Port)
|
|
fmt.Printf("Password: %s\n", s.Password)
|
|
}
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
ServerCmd.AddCommand(viewCmd)
|
|
}
|