ufcli

package
v0.0.0-...-3ccec1b Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0, MIT Imports: 19 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfStringFlag = altsrc.NewStringFlag
View Source
var DefaultHandledSignals = []os.Signal{
	unix.SIGTERM,
	unix.SIGINT,
	unix.SIGHUP,
	unix.SIGPIPE,
}

nolint:revive

Functions

This section is empty.

Types

type App

type App = cli.App

type BoolFlag

type BoolFlag = cli.BoolFlag

type Command

type Command = cli.Command

type Context

type Context = cli.Context

type Flag

type Flag = cli.Flag

type IntFlag

type IntFlag = cli.IntFlag

type Logger

type Logger = *logging.ZapEventLogger // FIXME make it an actual interface

nolint:revive

type StringFlag

type StringFlag = cli.StringFlag

type UFcli

type UFcli struct {
	AppConfig           cli.App                                                                     // stock urfavecli App configuration
	TOMLPath            string                                                                      // optional path of TOML config file read via https://pkg.go.dev/github.com/urfave/cli/v2/altsrc
	AllowConcurrentRuns bool                                                                        // if set allows multiple concurrent runs of the same command
	GlobalInit          func(cctx *cli.Context, uf *UFcli) (resourceCloser func() error, err error) // optional initialization routines (setup RDBMS pool, etc)
	BeforeShutdown      func() error                                                                // optional function to execute before the top context is cancelled ( unlike resourceCloser above )
	HandleSignals       []os.Signal                                                                 // if empty defaults to DefaultHandledSignals
	Logger              Logger                                                                      // optional ZapEventLogger-compatible object
	// contains filtered or unexported fields
}

UFcli is a urfavecli/v2/cli.App wrapper with simplified error and signal handling. It also provides correct init/shutdown hookpoints, and proper locking preventing the same app/command from running more than once.

func (*UFcli) GetLogger

func (uf *UFcli) GetLogger() Logger

GetLogger returns the configured Logger object

func (*UFcli) RunAndExit

func (uf *UFcli) RunAndExit(parentCtx context.Context)

RunAndExit will excute any init routines, run the app, and os.Exit() after shutdown

type UintFlag

type UintFlag = cli.UintFlag

Jump to

Keyboard shortcuts

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