// // cli_list.go // Copyright (C) 2022 tiglog // // Distributed under terms of the MIT license. // package console import "fmt" type cList struct { BaseCmd cli IConsole } func NewListCmd(cli IConsole) *cList { return &cList{ BaseCmd{ Name: "list", Desc: "列出支持的命令", }, cli, } } func (c *cList) Init(args []string) { c.Action = func() error { fmt.Printf("Usage: %s []\n\n%s\n\nCommands:\n", c.cli.GetName(), c.cli.GetDesc()) cmds := c.cli.GetCmds() for _, cmd := range cmds { fmt.Printf("%8s: %s\n", cmd.GetName(), cmd.GetDesc()) } fmt.Println() return nil } } func (c *cList) GetHelp() string { return c.Desc }