|
|
|
@ -81,6 +81,24 @@ func ShowVersion(c *Context) {
|
|
|
|
|
fmt.Printf("%v version %v\n", c.App.Name, c.App.Version)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Prints the lists of commands within a given context
|
|
|
|
|
func ShowCompletions(c *Context) {
|
|
|
|
|
for _, command := range c.App.Commands {
|
|
|
|
|
fmt.Println(command.Name)
|
|
|
|
|
if command.ShortName != "" {
|
|
|
|
|
fmt.Println(command.ShortName)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Prints the custom completions for a given command
|
|
|
|
|
func ShowCommandCompletions(ctx *Context, command string) {
|
|
|
|
|
c := ctx.App.Command(command)
|
|
|
|
|
if c != nil && c.BashComplete != nil {
|
|
|
|
|
c.BashComplete(ctx)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func printHelp(templ string, data interface{}) {
|
|
|
|
|
w := tabwriter.NewWriter(os.Stdout, 0, 8, 1, '\t', 0)
|
|
|
|
|
t := template.Must(template.New("help").Parse(templ))
|
|
|
|
@ -117,3 +135,21 @@ func checkCommandHelp(c *Context, name string) bool {
|
|
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func checkCompletions(c *Context) bool {
|
|
|
|
|
if c.GlobalBool("generate-bash-completion") {
|
|
|
|
|
ShowCompletions(c)
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func checkCommandCompletions(c *Context, name string) bool {
|
|
|
|
|
if c.Bool("generate-bash-completion") {
|
|
|
|
|
ShowCommandCompletions(c, name)
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|