cli

package
v1.14.2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: MIT Imports: 15 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CLI

type CLI struct {
	*huma.Router
	// contains filtered or unexported fields
}

CLI provides a command line interface to a Huma router.

func New

func New(router *huma.Router) *CLI

New creates a new CLI instance from an existing router.

func NewRouter

func NewRouter(docs, version string) *CLI

NewRouter creates a new router, new CLI, sets the default middlware, and returns the CLI/router as a convenience function.

func (*CLI) ArgsParsed

func (c *CLI) ArgsParsed(f func())

ArgsParsed registers a function to run after arguments have been parsed but before any command handler has been run. It is similar to a PreStart function but runs *before* PreStart functions and can be used for more than server startup, i.e. custom commands as well.

func (*CLI) Flag

func (c *CLI) Flag(name, short, description string, defaultValue interface{})

Flag adds a new global flag on the root command of this router.

func (*CLI) PreStart

func (c *CLI) PreStart(f func())

PreStart registers a function to run before the server starts but after command line arguments have been parsed.

func (*CLI) Root

func (c *CLI) Root() *cobra.Command

Root returns the CLI's root command. Use this to add flags and custom commands to the CLI.

func (*CLI) Run

func (c *CLI) Run()

Run runs the CLI.

Jump to

Keyboard shortcuts

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