Documentation
¶
Index ¶
- func DefaultHostFlag(defaultHost string, envVar string) cli.Flag
- func FlagName(flag cli.Flag) string
- func HelpPrinter(w io.Writer, templ string, data any)
- func ListPrint(w io.Writer, category string, data map[string]string, indent int, offset int, ...)
- func MapCommands(commands []*cli.Command) map[string]string
- func MapFlags(flags []cli.Flag) map[string]string
- type CliContext
- type OpenApiCli
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultHostFlag ¶
DefaultHostFlag returns the default --host flag configuration. Override by setting OpenApiCli.HostFlag before calling New().
func HelpPrinter ¶
HelpPrinter is a custom printer for OpenAPI commands. The base docs URL can be overridden by setting the OKAPI_DOCS_URL environment variable.
func ListPrint ¶
func ListPrint(w io.Writer, category string, data map[string]string, indent int, offset int, width int)
ListPrint is used to print lists of commands and flags
func MapCommands ¶
MapCommands creates a map of command names to usage string, which is used in the help printer
Types ¶
type CliContext ¶
type CliContext interface {
Stdin() *os.File
Stdout() io.Writer
Host() string
SetHost(host string)
GetApiClient() request.OpenApiClient
EmitJsonObj(obj any) error
Error(msg string) error
}
CliContext defines the runtime context needed by OpenApiCli. Consumers implement this to bridge their application context into Okapi.
type OpenApiCli ¶
type OpenApiCli struct {
Api *openapi.OpenApi
App *cli.App
AppName string // CLI binary name (e.g. "okapi")
DocsURL string // Base URL for documentation links
HostFlag cli.Flag
// contains filtered or unexported fields
}
OpenApiCli is a wrapper around the cli.App which allows it to integrate with the base CLI commands of the consuming application.
func (*OpenApiCli) Commands ¶
func (o *OpenApiCli) Commands() []*cli.Command
Commands returns the commands in the OpenApiCli
func (*OpenApiCli) Run ¶
func (o *OpenApiCli) Run(ctx CliContext, args []string) error
Run runs the OpenApiCli