Documentation ¶
Overview ¶
app provide a convenient application structure with commandline and profile features.
Index ¶
- type App
- func (app *App) Command(name string, desc string) *kingpin.CmdClause
- func (app *App) CpuProf() string
- func (app *App) EnableNoShutdownHook(noShutdownHook bool)
- func (app *App) Flag(longName string, desc string) *kingpin.FlagClause
- func (app *App) IsLogLevelNone() bool
- func (app *App) LogLevel() log.Priority
- func (app *App) MemProf() string
- func (app *App) ParseCommandLine(args []string) string
- func (app *App) StartProfile() error
- func (app *App) StopProfile()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is app structure with commandline and profile features.
func New ¶
New creates a new application according to name, description and version. There are some default command line flag:
verbose(v for short): show much more message, shorthand for --loglevel debug which will be ignored if loglevel is specificed. loglevel(l for short): set log level, possible value is error/warn/info/debug/no, info is default. memprof: the file to save memory profile. cpuprof: the file to save cpu profile.
func (*App) EnableNoShutdownHook ¶
EnableNoHookShutdown enables or disable shutdown hook. If shutdown hook is disabled, StopProfile is needed to be called.
func (*App) IsLogLevelNone ¶
func (*App) ParseCommandLine ¶
ParseCommandLine will parse command line which should not contains the executable name, and then return the sub-command. Exit if parse failed.
func (*App) StartProfile ¶
StartProfile starts all possible profiles.
func (*App) StopProfile ¶
func (app *App) StopProfile()
StopProfile stop profile, this should be called when shutdown hook is disabled, and this method does nothing when shutdown hook is enabled.