Documentation ¶
Index ¶
- func NewCLIApp(options ...CLIAppOption) *cli.App
- func NewCommand(command *cli.Command, options ...CommandOption) *cli.Command
- type AfterHandler
- type Application
- type BeforeHandler
- type CLIAppOption
- type Clock
- type CommandHandler
- type CommandOption
- type Environment
- type FakeClock
- type Handler
- type HandlerContext
- type HandlerOption
- func UseArguments[P any](mapping func(*P, []string)) HandlerOption[P]
- func UseBoolFlag[P any](flag *cli.BoolFlag, mapping func(*P, bool)) HandlerOption[P]
- func UseStringFlag[P any](flag *cli.StringFlag, mapping func(*P, string)) HandlerOption[P]
- func UseStringSliceFlag[P any](flag *cli.StringSliceFlag, mapping func(*P, []string)) HandlerOption[P]
- type OnUsageErrorHandler
- type SystemClock
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCLIApp ¶
func NewCLIApp(options ...CLIAppOption) *cli.App
func NewCommand ¶
func NewCommand(command *cli.Command, options ...CommandOption) *cli.Command
Types ¶
type AfterHandler ¶
type AfterHandler[P any] interface { After(ctx *HandlerContext[P], params *P, w io.Writer) error }
type Application ¶
type Application struct {
// contains filtered or unexported fields
}
func NewApplication ¶
func NewApplication(env *Environment, cli *cli.App) *Application
func (*Application) Run ¶
func (app *Application) Run(ctx context.Context)
type BeforeHandler ¶
type BeforeHandler[P any] interface { Before(ctx *HandlerContext[P], params *P, w io.Writer) error }
type CLIAppOption ¶
type CLIAppOption func(*cli.App)
func UseCommands ¶
func UseCommands(commands ...*cli.Command) CLIAppOption
func UseDefaultCommand ¶
func UseDefaultCommand(command string) CLIAppOption
func UseEnvironment ¶
func UseEnvironment(env *Environment) CLIAppOption
type CommandHandler ¶
type CommandHandler[P any] interface { Action(ctx *HandlerContext[P], params *P, w io.Writer) error }
type CommandOption ¶
type CommandOption func(*cli.Command)
func UseHandler ¶
func UseHandler[P any](handler CommandHandler[P], opts ...HandlerOption[P]) CommandOption
type Environment ¶
type Handler ¶
type Handler[P any] struct { CommandHandler[P] // contains filtered or unexported fields }
func NewHandler ¶
func NewHandler[P any](commandHandler CommandHandler[P], opts ...HandlerOption[P]) *Handler[P]
type HandlerContext ¶
type HandlerContext[P any] struct { Reader io.Reader Log *zerolog.Logger // contains filtered or unexported fields }
func (*HandlerContext[P]) Deadline ¶
func (ctx *HandlerContext[P]) Deadline() (deadline time.Time, ok bool)
func (*HandlerContext[P]) Done ¶
func (ctx *HandlerContext[P]) Done() <-chan struct{}
func (*HandlerContext[P]) Err ¶
func (ctx *HandlerContext[P]) Err() error
func (*HandlerContext[P]) Value ¶
func (ctx *HandlerContext[P]) Value(key any) any
type HandlerOption ¶
type HandlerOption[P any] func(*Handler[P]) CommandOption
func UseArguments ¶
func UseArguments[P any](mapping func(*P, []string)) HandlerOption[P]
func UseBoolFlag ¶
func UseBoolFlag[P any](flag *cli.BoolFlag, mapping func(*P, bool)) HandlerOption[P]
func UseStringFlag ¶
func UseStringFlag[P any](flag *cli.StringFlag, mapping func(*P, string)) HandlerOption[P]
func UseStringSliceFlag ¶
func UseStringSliceFlag[P any](flag *cli.StringSliceFlag, mapping func(*P, []string)) HandlerOption[P]
type OnUsageErrorHandler ¶
type SystemClock ¶
type SystemClock struct{}
func (*SystemClock) Now ¶
func (st *SystemClock) Now() time.Time
Click to show internal directories.
Click to hide internal directories.