merging code

This commit is contained in:
Summer Mousa
2014-04-10 12:14:13 -05:00
parent 3fa24ca4f3
commit 0b29bee364
3 changed files with 49 additions and 0 deletions

36
help.go
View File

@@ -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
}