Rename Stdout -> Writer
This commit is contained in:
22
app.go
22
app.go
@@ -40,8 +40,8 @@ type App struct {
|
||||
Author string
|
||||
// Author e-mail
|
||||
Email string
|
||||
// Stdout writer to write output to
|
||||
Stdout io.Writer
|
||||
// Writer writer to write output to
|
||||
Writer io.Writer
|
||||
}
|
||||
|
||||
// Tries to find out when this binary was compiled.
|
||||
@@ -65,7 +65,7 @@ func NewApp() *App {
|
||||
Compiled: compileTime(),
|
||||
Author: "Author",
|
||||
Email: "unknown@email",
|
||||
Stdout: os.Stdout,
|
||||
Writer: os.Stdout,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ func (a *App) Run(arguments []string) error {
|
||||
}()
|
||||
|
||||
HelpPrinter = func(templ string, data interface{}) {
|
||||
w := tabwriter.NewWriter(a.Stdout, 0, 8, 1, '\t', 0)
|
||||
w := tabwriter.NewWriter(a.Writer, 0, 8, 1, '\t', 0)
|
||||
t := template.Must(template.New("help").Parse(templ))
|
||||
err := t.Execute(w, data)
|
||||
if err != nil {
|
||||
@@ -105,18 +105,18 @@ func (a *App) Run(arguments []string) error {
|
||||
err := set.Parse(arguments[1:])
|
||||
nerr := normalizeFlags(a.Flags, set)
|
||||
if nerr != nil {
|
||||
io.WriteString(a.Stdout, fmt.Sprintln(nerr))
|
||||
io.WriteString(a.Writer, fmt.Sprintln(nerr))
|
||||
context := NewContext(a, set, set)
|
||||
ShowAppHelp(context)
|
||||
io.WriteString(a.Stdout, fmt.Sprintln(""))
|
||||
io.WriteString(a.Writer, fmt.Sprintln(""))
|
||||
return nerr
|
||||
}
|
||||
context := NewContext(a, set, set)
|
||||
|
||||
if err != nil {
|
||||
io.WriteString(a.Stdout, fmt.Sprintf("Incorrect Usage.\n\n"))
|
||||
io.WriteString(a.Writer, fmt.Sprintf("Incorrect Usage.\n\n"))
|
||||
ShowAppHelp(context)
|
||||
io.WriteString(a.Stdout, fmt.Sprintln(""))
|
||||
io.WriteString(a.Writer, fmt.Sprintln(""))
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -176,18 +176,18 @@ func (a *App) RunAsSubcommand(ctx *Context) error {
|
||||
context := NewContext(a, set, set)
|
||||
|
||||
if nerr != nil {
|
||||
io.WriteString(a.Stdout, fmt.Sprintln(nerr))
|
||||
io.WriteString(a.Writer, fmt.Sprintln(nerr))
|
||||
if len(a.Commands) > 0 {
|
||||
ShowSubcommandHelp(context)
|
||||
} else {
|
||||
ShowCommandHelp(ctx, context.Args().First())
|
||||
}
|
||||
io.WriteString(a.Stdout, fmt.Sprintln(""))
|
||||
io.WriteString(a.Writer, fmt.Sprintln(""))
|
||||
return nerr
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
io.WriteString(a.Stdout, fmt.Sprintf("Incorrect Usage.\n\n"))
|
||||
io.WriteString(a.Writer, fmt.Sprintf("Incorrect Usage.\n\n"))
|
||||
ShowSubcommandHelp(context)
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user