ourfave

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package ourfave provides the ability to create OpenCLI documents from existing urfave/cli v3 CLIs.

It attaches a hidden subcommand to an existing urfave/cli root command that, when invoked, walks the entire command tree and emits a valid OpenCLI spec document.

Typical usage:

var rootCmd = &cli.Command{Name: "myapp", Usage: "An awesome CLI"}
ourfave.FromCommand(rootCmd)
rootCmd.Run(os.Args)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromCommand

func FromCommand(rootCmd *cli.Command, opts ...Option)

FromCommand attaches a hidden "__opencli" subcommand to rootCmd. Running that subcommand walks the urfave/cli command tree and writes an OpenCLI spec document to the configured output (default: stdout).

func GenerateDocument

func GenerateDocument(rootCmd *cli.Command, opts ...Option) *spec.Document

GenerateDocument walks a urfave/cli command tree and returns the corresponding OpenCLI spec.Document. This is exported so callers can inspect or modify the document before serializing it themselves.

func GetBinaryName

func GetBinaryName(rootCmd *cli.Command) string

GetBinaryName extracts the binary name from a root command's Name field.

Types

type Option

type Option func(*config)

Option is a functional option for FromCommand.

func WithFormat

func WithFormat(f codec.Format) Option

WithFormat sets the output format ("yaml" or "json"). Defaults to YAML.

func WithGlobalFlags

func WithGlobalFlags(flags []spec.FlagItem) Option

WithGlobalFlags sets flags that apply globally (e.g. --help, --version).

func WithInfo

func WithInfo(info *spec.Info) Option

WithInfo sets the top-level spec.Info block. If omitted, only binary name (derived from root.Name) will be populated.

func WithInstallMethods

func WithInstallMethods(install []spec.InstallMethod) Option

WithInstallMethods sets the install methods list.

func WithOutput

func WithOutput(w io.Writer) Option

WithOutput sets the io.Writer for the generated spec. Defaults to os.Stdout if omitted.

Jump to

Keyboard shortcuts

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