cli

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(root any) error

Run executes the application based on the provided root struct. It parses the CLI arguments, resolves commands, binds flags, infuses dependencies, and runs lifecycle hooks.

Example:

func main() {
	app := &CLI{}
	if err := cli.Run(app); err != nil {
		log.Fatal(err)
	}
}

Types

type AfterRunner

type AfterRunner interface {
	After() error
}

AfterRunner is the interface that commands can implement to run logic after execution.

type Base

type Base struct {
	Logger log.Logger      `internal:"ignore"`
	Ctx    context.Context `internal:"ignore"`
}

Base is a struct that can be embedded in commands to provide common functionality.

type BeforeRunner

type BeforeRunner interface {
	Before() error
}

BeforeRunner is the interface that commands can implement to run logic before execution.

type Runner

type Runner interface {
	Run() error
}

Runner is the interface that commands must implement to be executed.

Jump to

Keyboard shortcuts

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