Update cli with new changes

This commit is contained in:
Harshavardhana
2015-03-29 13:38:30 -07:00
parent c728798137
commit 5defd8ffdd
5 changed files with 33 additions and 12 deletions
+18 -2
View File
@@ -71,6 +71,7 @@ var helpCommand = Command{
ShowAppHelp(c)
}
},
Hide: true,
}
var helpSubcommand = Command{
@@ -85,6 +86,7 @@ var helpSubcommand = Command{
ShowSubcommandHelp(c)
}
},
Hide: true,
}
// Prints help for the App
@@ -99,19 +101,27 @@ func ShowAppHelp(c *Context) {
// Make a copy of c.App context
app := *c.App
app.Flags = make([]Flag, 0)
app.Commands = make([]Command, 0)
for _, flag := range c.App.Flags {
if flag.isNotHidden() {
app.Flags = append(app.Flags, flag)
}
}
for _, command := range c.App.Commands {
if command.isNotHidden() {
app.Commands = append(app.Commands, command)
}
}
HelpPrinter(AppHelpTemplate, app)
}
// Prints the list of subcommands as the default app completion method
func DefaultAppComplete(c *Context) {
for _, command := range c.App.Commands {
for _, name := range command.Names() {
fmt.Fprintln(c.App.Writer, name)
if command.isNotHidden() {
for _, name := range command.Names() {
fmt.Fprintln(c.App.Writer, name)
}
}
}
}
@@ -123,11 +133,17 @@ func ShowCommandHelp(c *Context, command string) {
// Make a copy of c.App context
app := *c.App
app.Flags = make([]Flag, 0)
app.Commands = make([]Command, 0)
for _, flag := range c.App.Flags {
if flag.isNotHidden() {
app.Flags = append(app.Flags, flag)
}
}
for _, command := range c.App.Commands {
if command.isNotHidden() {
app.Commands = append(app.Commands, command)
}
}
HelpPrinter(SubcommandHelpTemplate, app)
return
}