Merge pull request #289 from KSubedi/master
Added command to have a custom text on the USAGE section of help
This commit is contained in:
commit
d5f087da9d
3
app.go
3
app.go
@ -18,6 +18,8 @@ type App struct {
|
|||||||
HelpName string
|
HelpName string
|
||||||
// Description of the program.
|
// Description of the program.
|
||||||
Usage string
|
Usage string
|
||||||
|
// Text to override the USAGE section of help
|
||||||
|
UsageText string
|
||||||
// Description of the program argument format.
|
// Description of the program argument format.
|
||||||
ArgsUsage string
|
ArgsUsage string
|
||||||
// Version of the program
|
// Version of the program
|
||||||
@ -78,6 +80,7 @@ func NewApp() *App {
|
|||||||
Name: path.Base(os.Args[0]),
|
Name: path.Base(os.Args[0]),
|
||||||
HelpName: path.Base(os.Args[0]),
|
HelpName: path.Base(os.Args[0]),
|
||||||
Usage: "A new cli application",
|
Usage: "A new cli application",
|
||||||
|
UsageText: "",
|
||||||
Version: "0.0.0",
|
Version: "0.0.0",
|
||||||
BashComplete: DefaultAppComplete,
|
BashComplete: DefaultAppComplete,
|
||||||
Action: helpCommand.Action,
|
Action: helpCommand.Action,
|
||||||
|
@ -24,6 +24,7 @@ func ExampleApp_Run() {
|
|||||||
app.Action = func(c *Context) {
|
app.Action = func(c *Context) {
|
||||||
fmt.Printf("Hello %v\n", c.String("name"))
|
fmt.Printf("Hello %v\n", c.String("name"))
|
||||||
}
|
}
|
||||||
|
app.UsageText = "app [first_arg] [second_arg]"
|
||||||
app.Author = "Harrison"
|
app.Author = "Harrison"
|
||||||
app.Email = "harrison@lolwut.com"
|
app.Email = "harrison@lolwut.com"
|
||||||
app.Authors = []Author{Author{Name: "Oliver Allen", Email: "oliver@toyshop.com"}}
|
app.Authors = []Author{Author{Name: "Oliver Allen", Email: "oliver@toyshop.com"}}
|
||||||
|
@ -16,6 +16,8 @@ type Command struct {
|
|||||||
Aliases []string
|
Aliases []string
|
||||||
// A short description of the usage of this command
|
// A short description of the usage of this command
|
||||||
Usage string
|
Usage string
|
||||||
|
// Custom text to show on USAGE section of help
|
||||||
|
UsageText string
|
||||||
// A longer explanation of how the command works
|
// A longer explanation of how the command works
|
||||||
Description string
|
Description string
|
||||||
// A short description of the arguments of this command
|
// A short description of the arguments of this command
|
||||||
|
2
help.go
2
help.go
@ -15,7 +15,7 @@ var AppHelpTemplate = `NAME:
|
|||||||
{{.Name}} - {{.Usage}}
|
{{.Name}} - {{.Usage}}
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
{{.HelpName}} {{if .Flags}}[global options]{{end}}{{if .Commands}} command [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}
|
{{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}} {{if .Flags}}[global options]{{end}}{{if .Commands}} command [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}
|
||||||
{{if .Version}}
|
{{if .Version}}
|
||||||
VERSION:
|
VERSION:
|
||||||
{{.Version}}
|
{{.Version}}
|
||||||
|
Loading…
Reference in New Issue
Block a user