app

package
v0.0.0-...-c18a219 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2023 License: MIT Imports: 12 Imported by: 12

Documentation

Index

Constants

View Source
const PkgName = "auxo.app"

Variables

View Source
var (
	// Version is the version of application
	Version string
	// SCMRevision is commit hash of source tree
	SCMRevision string
	// SCMBranch is current branch name the code is built off
	SCMBranch string
	// BuildTime is RFC3339 formatted UTC date, e.g. 2017-12-01T13:04:23Z
	BuildTime string
)
View Source
var (
	Name   string
	Desc   string
	Action func(ctx *Context) error
	Flags  = flag.Default
)
View Source
var (
	// Timeout is the amount of time allowed to wait graceful shutdown.
	Timeout = time.Second * 30
)

Functions

func AddCommand

func AddCommand(sub *Command)

func Ensure

func Ensure(err error)

Ensure exits program and log err if err is not nil.

func OnClose

func OnClose(fn func())

OnClose subscribes close events

func OnInit

func OnInit(fn func() error)

OnInit register an initializer which execute on app start. If fn return an error, the app will panic.

func Path

func Path() string

Path returns program's full filename

func Run

func Run(s Server, signals ...os.Signal)

Run executes program and subscribe exit signals.

func RunFunc

func RunFunc(runner ServeFunc, closer CloseFunc, signals ...os.Signal)

RunFunc executes program and subscribe exit signals.

func Start

func Start()

Types

type CloseFunc

type CloseFunc func(timeout time.Duration)

CloseFunc is server shutdown method.

type Command

type Command struct {
	Name   string
	Desc   string
	Action func(ctx *Context) error
	Flags  *flag.Set
	// contains filtered or unexported fields
}

func NewCommand

func NewCommand(name, desc string, action func(ctx *Context) error) *Command

func (*Command) AddCommand

func (c *Command) AddCommand(sub *Command)

type CommandSet

type CommandSet map[string]*Command

func (CommandSet) Add

func (cs CommandSet) Add(cmd *Command)

type Context

type Context struct {
	// contains filtered or unexported fields
}

func (*Context) Args

func (c *Context) Args() []string

Args returns the non-flag arguments.

func (*Context) Config

func (c *Context) Config() string

Config returns the config argument.

func (*Context) Help

func (c *Context) Help() bool

Help returns the help argument.

func (*Context) Profiles

func (c *Context) Profiles() []string

Profiles returns active profiles by command line.

func (*Context) Usage

func (c *Context) Usage()

Usage prints usage to os.Stdout.

func (*Context) Version

func (c *Context) Version() bool

Version returns the version argument.

type Error

type Error interface {
	error
	Code() int
}

func Fatal

func Fatal(code int, msg interface{}) Error

type ServeFunc

type ServeFunc func() error

ServeFunc is server execute method.

type Server

type Server interface {
	Serve() error
	Close(timeout time.Duration)
}

Server defines the interface of server application.

Directories

Path Synopsis
Package flag implements command-line flag parsing.
Package flag implements command-line flag parsing.

Jump to

Keyboard shortcuts

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