parent
02bba4b62e
commit
a05e4d0982
18
app.go
18
app.go
@ -9,7 +9,6 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const suggestDidYouMeanTemplate = "Did you mean %q?"
|
const suggestDidYouMeanTemplate = "Did you mean %q?"
|
||||||
@ -81,8 +80,6 @@ type App struct {
|
|||||||
OnUsageError OnUsageErrorFunc
|
OnUsageError OnUsageErrorFunc
|
||||||
// Execute this function when an invalid flag is accessed from the context
|
// Execute this function when an invalid flag is accessed from the context
|
||||||
InvalidFlagAccessHandler InvalidFlagAccessFunc
|
InvalidFlagAccessHandler InvalidFlagAccessFunc
|
||||||
// Compilation date
|
|
||||||
Compiled time.Time
|
|
||||||
// List of all authors who contributed
|
// List of all authors who contributed
|
||||||
Authors []*Author
|
Authors []*Author
|
||||||
// Copyright of the binary if any
|
// Copyright of the binary if any
|
||||||
@ -128,16 +125,6 @@ type SuggestFlagFunc func(flags []Flag, provided string, hideHelp bool) string
|
|||||||
|
|
||||||
type SuggestCommandFunc func(commands []*Command, provided string) string
|
type SuggestCommandFunc func(commands []*Command, provided string) string
|
||||||
|
|
||||||
// Tries to find out when this binary was compiled.
|
|
||||||
// Returns the current time if it fails to find it.
|
|
||||||
func compileTime() time.Time {
|
|
||||||
info, err := os.Stat(os.Args[0])
|
|
||||||
if err != nil {
|
|
||||||
return time.Now()
|
|
||||||
}
|
|
||||||
return info.ModTime()
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewApp creates a new cli Application with some reasonable defaults for Name,
|
// NewApp creates a new cli Application with some reasonable defaults for Name,
|
||||||
// Usage, Version and Action.
|
// Usage, Version and Action.
|
||||||
func NewApp() *App {
|
func NewApp() *App {
|
||||||
@ -147,7 +134,6 @@ func NewApp() *App {
|
|||||||
UsageText: "",
|
UsageText: "",
|
||||||
BashComplete: DefaultAppComplete,
|
BashComplete: DefaultAppComplete,
|
||||||
Action: helpCommand.Action,
|
Action: helpCommand.Action,
|
||||||
Compiled: compileTime(),
|
|
||||||
Reader: os.Stdin,
|
Reader: os.Stdin,
|
||||||
Writer: os.Stdout,
|
Writer: os.Stdout,
|
||||||
ErrWriter: os.Stderr,
|
ErrWriter: os.Stderr,
|
||||||
@ -188,10 +174,6 @@ func (a *App) Setup() {
|
|||||||
a.Action = helpCommand.Action
|
a.Action = helpCommand.Action
|
||||||
}
|
}
|
||||||
|
|
||||||
if a.Compiled == (time.Time{}) {
|
|
||||||
a.Compiled = compileTime()
|
|
||||||
}
|
|
||||||
|
|
||||||
if a.Reader == nil {
|
if a.Reader == nil {
|
||||||
a.Reader = os.Stdin
|
a.Reader = os.Stdin
|
||||||
}
|
}
|
||||||
|
@ -292,8 +292,6 @@ type App struct {
|
|||||||
OnUsageError OnUsageErrorFunc
|
OnUsageError OnUsageErrorFunc
|
||||||
// Execute this function when an invalid flag is accessed from the context
|
// Execute this function when an invalid flag is accessed from the context
|
||||||
InvalidFlagAccessHandler InvalidFlagAccessFunc
|
InvalidFlagAccessHandler InvalidFlagAccessFunc
|
||||||
// Compilation date
|
|
||||||
Compiled time.Time
|
|
||||||
// List of all authors who contributed
|
// List of all authors who contributed
|
||||||
Authors []*Author
|
Authors []*Author
|
||||||
// Copyright of the binary if any
|
// Copyright of the binary if any
|
||||||
|
2
testdata/godoc-v3.x.txt
vendored
2
testdata/godoc-v3.x.txt
vendored
@ -292,8 +292,6 @@ type App struct {
|
|||||||
OnUsageError OnUsageErrorFunc
|
OnUsageError OnUsageErrorFunc
|
||||||
// Execute this function when an invalid flag is accessed from the context
|
// Execute this function when an invalid flag is accessed from the context
|
||||||
InvalidFlagAccessHandler InvalidFlagAccessFunc
|
InvalidFlagAccessHandler InvalidFlagAccessFunc
|
||||||
// Compilation date
|
|
||||||
Compiled time.Time
|
|
||||||
// List of all authors who contributed
|
// List of all authors who contributed
|
||||||
Authors []*Author
|
Authors []*Author
|
||||||
// Copyright of the binary if any
|
// Copyright of the binary if any
|
||||||
|
Loading…
Reference in New Issue
Block a user