* added list and exec commands
This commit is contained in:
29
cmd/list/list.go
Normal file
29
cmd/list/list.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user