app, help: add backwards compatibility for Authors
This commit is contained in:
parent
05ecd63a95
commit
c6592bb487
12
app.go
12
app.go
@ -40,8 +40,12 @@ type App struct {
|
||||
CommandNotFound func(context *Context, command string)
|
||||
// Compilation date
|
||||
Compiled time.Time
|
||||
// Authors
|
||||
// List of all authors who contributed
|
||||
Authors []Author
|
||||
// Name of Author (Note: Use App.Authors, this is deprecated)
|
||||
Author string
|
||||
// Email of Author (Note: Use App.Authors, this is deprecated)
|
||||
Email string
|
||||
// Writer writer to write output to
|
||||
Writer io.Writer
|
||||
}
|
||||
@ -65,6 +69,8 @@ func NewApp() *App {
|
||||
BashComplete: DefaultAppComplete,
|
||||
Action: helpCommand.Action,
|
||||
Compiled: compileTime(),
|
||||
Author: "Dr. James",
|
||||
Email: "who@gmail.com",
|
||||
Authors: []Author{{"Jim", "jim@corporate.com"}, {"Hank", "hank@indiepalace.com"}},
|
||||
Writer: os.Stdout,
|
||||
}
|
||||
@ -72,6 +78,10 @@ func NewApp() *App {
|
||||
|
||||
// Entry point to the cli app. Parses the arguments slice and routes to the proper flag/args combination
|
||||
func (a *App) Run(arguments []string) error {
|
||||
if a.Author != "" && a.Author != "" {
|
||||
a.Authors = append(a.Authors, Author{a.Author, a.Email})
|
||||
}
|
||||
|
||||
if HelpPrinter == nil {
|
||||
defer func() {
|
||||
HelpPrinter = nil
|
||||
|
@ -21,8 +21,9 @@ func ExampleApp() {
|
||||
app.Action = func(c *cli.Context) {
|
||||
fmt.Printf("Hello %v\n", c.String("name"))
|
||||
}
|
||||
app.Author = "Harrison"
|
||||
app.Email = "harrison@lolwut.com"
|
||||
app.Authors = []cli.Author{{"Oliver Allen", "oliver@toyshop.com"}}
|
||||
|
||||
app.Run(os.Args)
|
||||
// Output:
|
||||
// Hello Jeremy
|
||||
|
Loading…
Reference in New Issue
Block a user