|
|
@ -3,6 +3,7 @@ package cli
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"io"
|
|
|
|
|
|
|
|
"os"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
"text/tabwriter"
|
|
|
|
"text/tabwriter"
|
|
|
|
"text/template"
|
|
|
|
"text/template"
|
|
|
@ -21,15 +22,15 @@ VERSION:
|
|
|
|
{{.Version}}
|
|
|
|
{{.Version}}
|
|
|
|
{{end}}{{end}}{{if len .Authors}}
|
|
|
|
{{end}}{{end}}{{if len .Authors}}
|
|
|
|
AUTHOR(S):
|
|
|
|
AUTHOR(S):
|
|
|
|
{{range .Authors}}{{ . }}{{end}}
|
|
|
|
{{range .Authors}}{{.}}{{end}}
|
|
|
|
{{end}}{{if .Commands}}
|
|
|
|
{{end}}{{if .VisibleCommands}}
|
|
|
|
COMMANDS:{{range .Categories}}{{if .Name}}
|
|
|
|
COMMANDS:{{range .VisibleCategories}}{{if .Name}}
|
|
|
|
{{.Name}}{{ ":" }}{{end}}{{range .Commands}}
|
|
|
|
{{.Name}}:{{end}}{{range .VisibleCommands}}
|
|
|
|
{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}}{{end}}
|
|
|
|
{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{"\t"}}{{.Usage}}{{end}}
|
|
|
|
{{end}}{{end}}{{if .VisibleFlags}}
|
|
|
|
{{end}}{{end}}{{if .VisibleFlags}}
|
|
|
|
GLOBAL OPTIONS:
|
|
|
|
GLOBAL OPTIONS:
|
|
|
|
{{range .VisibleFlags}}{{.}}
|
|
|
|
{{range .VisibleFlags}}{{.}}
|
|
|
|
{{end}}{{end}}{{if .Copyright }}
|
|
|
|
{{end}}{{end}}{{if .Copyright}}
|
|
|
|
COPYRIGHT:
|
|
|
|
COPYRIGHT:
|
|
|
|
{{.Copyright}}
|
|
|
|
{{.Copyright}}
|
|
|
|
{{end}}
|
|
|
|
{{end}}
|
|
|
@ -52,7 +53,7 @@ DESCRIPTION:
|
|
|
|
|
|
|
|
|
|
|
|
OPTIONS:
|
|
|
|
OPTIONS:
|
|
|
|
{{range .VisibleFlags}}{{.}}
|
|
|
|
{{range .VisibleFlags}}{{.}}
|
|
|
|
{{end}}{{ end }}
|
|
|
|
{{end}}{{end}}
|
|
|
|
`
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
|
|
// The text template for the subcommand help topic.
|
|
|
|
// The text template for the subcommand help topic.
|
|
|
@ -64,9 +65,9 @@ var SubcommandHelpTemplate = `NAME:
|
|
|
|
USAGE:
|
|
|
|
USAGE:
|
|
|
|
{{.HelpName}} command{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}
|
|
|
|
{{.HelpName}} command{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}
|
|
|
|
|
|
|
|
|
|
|
|
COMMANDS:{{range .Categories}}{{if .Name}}
|
|
|
|
COMMANDS:{{range .VisibleCategories}}{{if .Name}}
|
|
|
|
{{.Name}}{{ ":" }}{{end}}{{range .Commands}}
|
|
|
|
{{.Name}}:{{end}}{{range .VisibleCommands}}
|
|
|
|
{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}}{{end}}
|
|
|
|
{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{"\t"}}{{.Usage}}{{end}}
|
|
|
|
{{end}}{{if .VisibleFlags}}
|
|
|
|
{{end}}{{if .VisibleFlags}}
|
|
|
|
OPTIONS:
|
|
|
|
OPTIONS:
|
|
|
|
{{range .VisibleFlags}}{{.}}
|
|
|
|
{{range .VisibleFlags}}{{.}}
|
|
|
@ -120,6 +121,9 @@ func ShowAppHelp(c *Context) {
|
|
|
|
// Prints the list of subcommands as the default app completion method
|
|
|
|
// Prints the list of subcommands as the default app completion method
|
|
|
|
func DefaultAppComplete(c *Context) {
|
|
|
|
func DefaultAppComplete(c *Context) {
|
|
|
|
for _, command := range c.App.Commands {
|
|
|
|
for _, command := range c.App.Commands {
|
|
|
|
|
|
|
|
if command.Hidden {
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
}
|
|
|
|
for _, name := range command.Names() {
|
|
|
|
for _, name := range command.Names() {
|
|
|
|
fmt.Fprintln(c.App.Writer, name)
|
|
|
|
fmt.Fprintln(c.App.Writer, name)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -188,7 +192,10 @@ func printHelp(out io.Writer, templ string, data interface{}) {
|
|
|
|
err := t.Execute(w, data)
|
|
|
|
err := t.Execute(w, data)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
// If the writer is closed, t.Execute will fail, and there's nothing
|
|
|
|
// If the writer is closed, t.Execute will fail, and there's nothing
|
|
|
|
// we can do to recover. We could send this to ErrWriter if we need.
|
|
|
|
// we can do to recover.
|
|
|
|
|
|
|
|
if os.Getenv("CLI_TEMPLATE_ERROR_DEBUG") != "" {
|
|
|
|
|
|
|
|
fmt.Fprintf(ErrWriter, "CLI TEMPLATE ERROR: %#v\n", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
w.Flush()
|
|
|
|
w.Flush()
|
|
|
|