Documentation ¶
Index ¶
- func FuncToApp(f any) *cli.App
- func GetFlag[T any](ctx *Context, f any, name string) (T, error)
- func PartsToCommands(parts []AppPart) []*cli.Command
- func Register(app any, config RunConfig)
- func Run(f any)
- func RunE(f any) error
- func RunWithArgsE(f any, args []string) error
- type AppPart
- type Application
- type Context
- type FluentFlag
- type FluentSelf
- type GoatCommand
- type GoatGroup
- type RunConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PartsToCommands ¶
func PartsToCommands(parts []AppPart) []*cli.Command
func Register ¶
Register registers a RunConfig generated from a function.
This is only used in generated code.
func Run ¶
func Run(f any)
Run takes a free function and runs it as a CLI app, terminating with a log if an error occurs.
func RunWithArgsE ¶
Types ¶
type Application ¶
type Application struct{ *cli.App }
func App ¶
func App(name string, commands ...AppPart) Application
func (Application) Run ¶
func (app Application) Run()
func (Application) RunE ¶
func (app Application) RunE() error
func (Application) RunWithArgsE ¶
func (app Application) RunWithArgsE(args []string) error
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func GetContext ¶
func GetContext(c *cli.Context) *Context
type FluentFlag ¶
type FluentFlag struct{}
func Flag ¶
func Flag(any) FluentFlag
Flag creates a flag-descriptor to be used during code-generation to describe the flag.
Should be used with the FluentFlag.Name, FluentFlag.Usage and FluentFlag.Default methods.
Example:
func f(myFlag int) { Flag(myFlag). Name("my-flag"). Usage("Just a flag.") }
func (FluentFlag) Default ¶
func (f FluentFlag) Default(any) FluentFlag
Default sets the default value for a flag.
Must be called with the same type as the flag.
func (FluentFlag) Usage ¶
func (f FluentFlag) Usage(string) FluentFlag
Usage sets the usage of a flag.
type FluentSelf ¶
type FluentSelf struct{}
func (FluentSelf) Name ¶
func (s FluentSelf) Name(string) FluentSelf
Name sets the name of the current function.
func (FluentSelf) Usage ¶
func (s FluentSelf) Usage(string) FluentSelf
Usage sets the usage of the current function.
type GoatCommand ¶
type GoatCommand struct {
// contains filtered or unexported fields
}
func Command ¶
func Command(f any, subcommands ...AppPart) *GoatCommand
type RunConfig ¶
type RunConfig struct { Flags []cli.Flag // TODO: Replace this with a function that takes the action function and returns ActionFunc // This is needed for supporting function literals instead of named functions. // This is also required for anything beyond named functions. Action cli.ActionFunc CtxFlagBuilder func(c *cli.Context) map[string]any Name string Usage string }
Click to show internal directories.
Click to hide internal directories.