cli

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultHostFlag

func DefaultHostFlag(defaultHost string, envVar string) cli.Flag

DefaultHostFlag returns the default --host flag configuration. Override by setting OpenApiCli.HostFlag before calling New().

func FlagName

func FlagName(flag cli.Flag) string

FlagName returns flag with prepended hyphens, and joins multiple flag names

func HelpPrinter

func HelpPrinter(w io.Writer, templ string, data any)

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

func MapCommands(commands []*cli.Command) map[string]string

MapCommands creates a map of command names to usage string, which is used in the help printer

func MapFlags

func MapFlags(flags []cli.Flag) map[string]string

MapFlags creates a map of flag 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) New

func (o *OpenApiCli) New() *OpenApiCli

New creates a new OpenApiCli

func (*OpenApiCli) Run

func (o *OpenApiCli) Run(ctx CliContext, args []string) error

Run runs the OpenApiCli

Jump to

Keyboard shortcuts

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