* added list and exec commands

This commit is contained in:
Denys Seredenko
2025-01-12 11:38:01 +01:00
commit b8f7766de8
6 changed files with 200 additions and 0 deletions

29
cmd/list/list.go Normal file
View File

@@ -0,0 +1,29 @@
package list
import (
"github.com/jedib0t/go-pretty/v6/table"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"os"
)
var listCmd = &cobra.Command{
Use: "list",
Short: "List all known commands and their aliases",
Run: func(cmd *cobra.Command, args []string) {
t := table.NewWriter()
t.SetOutputMirror(os.Stdout)
t.AppendHeader(table.Row{"Alias", "Command"})
commands := viper.GetStringMapString("data")
for alias, command := range commands {
t.AppendRow(table.Row{alias, command})
}
t.Render()
},
}
func Cmd() *cobra.Command {
return listCmd
}