urfave

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package urfave adapts Conductor to urfave/cli v3 CLIs: one call wires themed help, shell completions, standard flags, version output and update notifications onto an existing root command, mirroring the conventions of clib's cli/urfave package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UpdateCommand

func UpdateCommand(app *conductor.Runtime) *clilib.Command

UpdateCommand returns the standard self-update subcommand. It dispatches on App.Updater's install method (brew, goinstall or github); tools distributed another way provide their own update command instead.

func VersionCommand

func VersionCommand(app *conductor.Runtime) *clilib.Command

VersionCommand returns the standard `version` subcommand.

Types

type Flags

type Flags struct {
	Verbose bool
	Quiet   bool
	Color   clog.ColorMode
}

Flags are the standard flags: verbosity and color. New prepends them to the root command's flags and applies them in the chained Before hook.

func (*Flags) ConductorFlags

func (f *Flags) ConductorFlags() conductor.Flags

ConductorFlags implements conductor.FlagSource.

type Option

type Option func(*Program)

Option configures New.

func WithExitCode

func WithExitCode(fn func(error) int) Option

WithExitCode maps command errors to exit codes; see conductor.ExitCode.

func WithGenerator

func WithGenerator(fn func(*complete.Generator)) Option

WithGenerator customises the completion generator before completion actions run, e.g. to add dynamic argument specs.

func WithSections

func WithSections(opts ...cliburfave.SectionsOption) Option

WithSections configures the help section builder.

func WithUpdateCommand

func WithUpdateCommand() Option

WithUpdateCommand adds the standard Homebrew `update` subcommand.

func WithVersionCommand

func WithVersionCommand() Option

WithVersionCommand adds the standard `version` subcommand.

type Program

type Program struct {
	Runtime    *conductor.Runtime
	Root       *clilib.Command
	Completion *cliburfave.Completion
	Flags      *Flags
	// contains filtered or unexported fields
}

Program is the assembled urfave CLI. All fields are exported and may be customised between New and Program.Run.

func New

func New(app *conductor.Runtime, root *clilib.Command, opts ...Option) *Program

New wires Conductor onto root: identity defaults from the App, themed help (via the package-global clilib.HelpPrinter), prepended standard flags, a -V/--version flag (replacing urfave's -v alias, which the verbose flag claims), completion flags, and a chained Before hook that applies the standard flags and starts the update notification.

func (*Program) Generator

func (p *Program) Generator() *complete.Generator

Generator builds the completion generator from the assembled command tree.

func (*Program) Run

func (p *Program) Run(ctx context.Context, args []string) int

Run is the one-call happy path: completion preflight, run, deferred update-hint flush, and exit code mapping. args is the full argument vector including the program name (os.Args, urfave's convention). The caller passes the result to os.Exit.

Jump to

Keyboard shortcuts

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