30 lines
578 B
Go
30 lines
578 B
Go
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
|
|
}
|