lots o progress
- added 'command' subcommand - removed viper - setup commands added - still a WIP - readme TODO update
This commit is contained in:
37
cmd/server/view.go
Normal file
37
cmd/server/view.go
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user