|
|
|
@ -118,6 +118,7 @@ func NewApp() *App {
|
|
|
|
|
Action: helpCommand.Action,
|
|
|
|
|
Compiled: compileTime(),
|
|
|
|
|
Writer: os.Stdout,
|
|
|
|
|
ErrWriter: os.Stderr,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -163,6 +164,10 @@ func (a *App) Setup() {
|
|
|
|
|
a.Writer = os.Stdout
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if a.ErrWriter == nil {
|
|
|
|
|
a.ErrWriter = os.Stderr
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var newCommands []*Command
|
|
|
|
|
|
|
|
|
|
for _, c := range a.Commands {
|
|
|
|
@ -196,10 +201,6 @@ func (a *App) Setup() {
|
|
|
|
|
if a.Metadata == nil {
|
|
|
|
|
a.Metadata = make(map[string]interface{})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if a.Writer == nil {
|
|
|
|
|
a.Writer = os.Stdout
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *App) newFlagSet() (*flag.FlagSet, error) {
|
|
|
|
@ -326,7 +327,7 @@ func (a *App) RunContext(ctx context.Context, arguments []string) (err error) {
|
|
|
|
|
// code in the cli.ExitCoder
|
|
|
|
|
func (a *App) RunAndExitOnError() {
|
|
|
|
|
if err := a.Run(os.Args); err != nil {
|
|
|
|
|
_, _ = fmt.Fprintln(a.errWriter(), err)
|
|
|
|
|
_, _ = fmt.Fprintln(a.ErrWriter, err)
|
|
|
|
|
OsExiter(1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -480,15 +481,6 @@ func (a *App) VisibleFlags() []Flag {
|
|
|
|
|
return visibleFlags(a.Flags)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *App) errWriter() io.Writer {
|
|
|
|
|
// When the app ErrWriter is nil use the package level one.
|
|
|
|
|
if a.ErrWriter == nil {
|
|
|
|
|
return ErrWriter
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return a.ErrWriter
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *App) appendFlag(fl Flag) {
|
|
|
|
|
if !hasFlag(a.Flags, fl) {
|
|
|
|
|
a.Flags = append(a.Flags, fl)
|
|
|
|
|