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 ¶
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 ¶
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 ¶
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 ¶
WithFormat sets the output format ("yaml" or "json"). Defaults to YAML.
func WithGlobalFlags ¶
WithGlobalFlags sets flags that apply globally (e.g. --help, --version).
func WithInfo ¶
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 ¶
WithOutput sets the io.Writer for the generated spec. Defaults to os.Stdout if omitted.