lots o progress
- added 'command' subcommand - removed viper - setup commands added - still a WIP - readme TODO update
This commit is contained in:
35
cmd/command/view.go
Normal file
35
cmd/command/view.go
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
Copyright © 2025 Jake jake.young.dev@gmail.com
|
||||
*/
|
||||
package command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"code.jakeyoungdev.com/jake/mctl/database"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var viewCmd = &cobra.Command{
|
||||
Use: "view",
|
||||
Example: "mctl command view",
|
||||
// Short: "view all commands",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
db, err := database.New()
|
||||
cobra.CheckErr(err)
|
||||
defer db.Close()
|
||||
|
||||
ts, err := db.GetAllCmds()
|
||||
cobra.CheckErr(err)
|
||||
|
||||
for _, s := range ts {
|
||||
fmt.Println("-----")
|
||||
fmt.Printf("Name: %s\n", s.Name)
|
||||
fmt.Printf("Command: %s\n", s.Command)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
CommandCmd.AddCommand(viewCmd)
|
||||
}
|
||||
Reference in New Issue
Block a user