app

package
v0.0.0-...-dddda54 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

app provide a convenient application structure with commandline and profile features.

Index

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

func New(name string, desc string, version string) *App

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) Command

func (app *App) Command(name string, desc string) *kingpin.CmdClause

Command extends an sub-command. see kingpin for details.

func (*App) CpuProf

func (app *App) CpuProf() string

CpuProf returns cpu profile's path

func (*App) EnableNoShutdownHook

func (app *App) EnableNoShutdownHook(noShutdownHook bool)

EnableNoHookShutdown enables or disable shutdown hook. If shutdown hook is disabled, StopProfile is needed to be called.

func (*App) Flag

func (app *App) Flag(longName string, desc string) *kingpin.FlagClause

Flag extends a new global flag. see kingpin for details.

func (*App) IsLogLevelNone

func (app *App) IsLogLevelNone() bool

func (*App) LogLevel

func (app *App) LogLevel() log.Priority

LogLevel returns the log level.

func (*App) MemProf

func (app *App) MemProf() string

MemProf returns memory profile's path.

func (*App) ParseCommandLine

func (app *App) ParseCommandLine(args []string) string

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

func (app *App) StartProfile() error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL