Documentation
¶
Index ¶
- Constants
- Variables
- func AppFromContext(ctx CommandContext) (forge.App, bool)
- func Colorize(colorFunc func(...any) string, s string) string
- func ConfigureColors(config ColorConfig)
- func FormatError(err error, colors bool) string
- func GenerateBashCompletion(cli CLI, w io.Writer) error
- func GenerateFishCompletion(cli CLI, w io.Writer) error
- func GenerateZshCompletion(cli CLI, w io.Writer) error
- func GetExitCode(err error) int
- func GetService[T any](ctx CommandContext) (T, error)
- func MultiSelectAsync(ctx context.Context, question string, loader OptionsLoader) ([]string, error)
- func MultiSelectWithProgressFeedback(ctx context.Context, question string, loader ProgressLoader) ([]string, error)
- func MultiSelectWithRetry(ctx context.Context, question string, loader OptionsLoader, maxRetries int) ([]string, error)
- func MustGetApp(ctx CommandContext) forge.App
- func MustGetService[T any](ctx CommandContext) T
- func PromptPassword(question string) (string, error)
- func PromptWithDefault(question, defaultValue string) (string, error)
- func RunApp(setup AppSetup, opts ...RunAppOption)
- func SelectAsync(ctx context.Context, question string, loader OptionsLoader) (string, error)
- func SelectWithProgressFeedback(ctx context.Context, question string, loader ProgressLoader) (string, error)
- func SelectWithRetry(ctx context.Context, question string, loader OptionsLoader, maxRetries int) (string, error)
- func WithApp(app forge.App) func(*Config)
- type AppRunner
- func (r *AppRunner) AutoMigrate() *AppRunner
- func (r *AppRunner) Description(desc string) *AppRunner
- func (r *AppRunner) DisableMigrationCommands() *AppRunner
- func (r *AppRunner) DisableServeCommand() *AppRunner
- func (r *AppRunner) Execute() error
- func (r *AppRunner) Name(name string) *AppRunner
- func (r *AppRunner) Run()
- func (r *AppRunner) Version(version string) *AppRunner
- func (r *AppRunner) WithExtraCommands(cmds ...Command) *AppRunner
- func (r *AppRunner) WithGlobalFlags(flags ...Flag) *AppRunner
- type AppSetup
- type BasePlugin
- func (p *BasePlugin) AddCommand(cmd Command)
- func (p *BasePlugin) AddDependency(dep string)
- func (p *BasePlugin) Commands() []Command
- func (p *BasePlugin) Dependencies() []string
- func (p *BasePlugin) Description() string
- func (p *BasePlugin) Initialize() error
- func (p *BasePlugin) Name() string
- func (p *BasePlugin) SetCommands(commands []Command)
- func (p *BasePlugin) SetDependencies(dependencies []string)
- func (p *BasePlugin) Version() string
- type CLI
- type CLIError
- type CLILogger
- func (l *CLILogger) Debug(msg string, args ...any)
- func (l *CLILogger) Error(msg string, args ...any)
- func (l *CLILogger) Info(msg string, args ...any)
- func (l *CLILogger) NewLine()
- func (l *CLILogger) Print(msg string, args ...any)
- func (l *CLILogger) Printf(format string, args ...any)
- func (l *CLILogger) Println(args ...any)
- func (l *CLILogger) Separator()
- func (l *CLILogger) SetColors(enabled bool)
- func (l *CLILogger) SetLevel(level LogLevel)
- func (l *CLILogger) SetOutput(w io.Writer)
- func (l *CLILogger) Success(msg string, args ...any)
- func (l *CLILogger) Warning(msg string, args ...any)
- type ColorConfig
- type Command
- type CommandContext
- type CommandHandler
- type CommandOption
- func WithAfter(fn MiddlewareFunc) CommandOption
- func WithAliases(aliases ...string) CommandOption
- func WithBefore(fn MiddlewareFunc) CommandOption
- func WithFlag(flag Flag) CommandOption
- func WithFlags(flags ...Flag) CommandOption
- func WithSubcommand(sub Command) CommandOption
- func WithUsage(usage string) CommandOption
- type Config
- type Flag
- func NewBoolFlag(name, shortName, description string, defaultValue bool, opts ...FlagOption) Flag
- func NewDurationFlag(name, shortName, description string, defaultValue time.Duration, ...) Flag
- func NewFlag(name string, flagType FlagType, opts ...FlagOption) Flag
- func NewIntFlag(name, shortName, description string, defaultValue int, opts ...FlagOption) Flag
- func NewStringFlag(name, shortName, description, defaultValue string, opts ...FlagOption) Flag
- func NewStringSliceFlag(name, shortName, description string, defaultValue []string, opts ...FlagOption) Flag
- type FlagOption
- func Required() FlagOption
- func ValidateEnum(allowed ...string) FlagOption
- func ValidateRange(minVal, maxVal int) FlagOption
- func WithAlias(alias string) FlagOption
- func WithBoolFlag(name, shortName, description string, defaultValue bool, opts ...FlagOption) FlagOption
- func WithDefault(value any) FlagOption
- func WithDescription(desc string) FlagOption
- func WithDurationFlag(name, shortName, description string, defaultValue time.Duration, ...) FlagOption
- func WithIntFlag(name, shortName, description string, defaultValue int, opts ...FlagOption) FlagOption
- func WithStringFlag(name, shortName, description, defaultValue string, opts ...FlagOption) FlagOption
- func WithStringSliceFlag(name, shortName, description string, defaultValue []string, opts ...FlagOption) FlagOption
- func WithValidator(validator func(any) error) FlagOption
- type FlagType
- type FlagValue
- type LogLevel
- type LoggerOption
- type MiddlewareFunc
- type OptionsLoader
- type Plugin
- type PluginMetadata
- type PluginRegistry
- func (r *PluginRegistry) All() []Plugin
- func (r *PluginRegistry) Count() int
- func (r *PluginRegistry) Get(name string) (Plugin, error)
- func (r *PluginRegistry) GetMetadata(name string) (*PluginMetadata, error)
- func (r *PluginRegistry) Has(name string) bool
- func (r *PluginRegistry) Metadata() []*PluginMetadata
- func (r *PluginRegistry) Names() []string
- func (r *PluginRegistry) Register(plugin Plugin) error
- func (r *PluginRegistry) RegisterAll(plugins []Plugin) error
- type ProgressBar
- type ProgressLoader
- type RunAppOption
- func WithAutoMigrate() RunAppOption
- func WithCLIDescription(description string) RunAppOption
- func WithCLIName(name string) RunAppOption
- func WithCLIVersion(version string) RunAppOption
- func WithDisableMigrationCommands() RunAppOption
- func WithDisableServeCommand() RunAppOption
- func WithExtraCommands(cmds ...Command) RunAppOption
- func WithGlobalFlags(flags ...Flag) RunAppOption
- type Spinner
- type TableAlignment
- type TableStyle
- type TableWriter
Constants ¶
const ( ExitSuccess = 0 ExitError = 1 ExitUsageError = 2 ExitNotFound = 127 ExitInternalError = 3 )
Common exit codes.
Variables ¶
var ( // Green applies green color to output. Green = color.New(color.FgGreen).SprintFunc() // Red applies red color to output. Red = color.New(color.FgRed).SprintFunc() // Yellow applies yellow color to output. Yellow = color.New(color.FgYellow).SprintFunc() // Blue applies blue color to output. Blue = color.New(color.FgBlue).SprintFunc() // Cyan applies cyan color to output. Cyan = color.New(color.FgCyan).SprintFunc() // Magenta applies magenta color to output. Magenta = color.New(color.FgMagenta).SprintFunc() // White applies white color to output. White = color.New(color.FgWhite).SprintFunc() // Gray applies gray color to output. Gray = color.New(color.FgHiBlack).SprintFunc() // Bold applies bold style to output. Bold = color.New(color.Bold).SprintFunc() // Underline applies underline style to output. Underline = color.New(color.Underline).SprintFunc() // Italic applies italic style to output. Italic = color.New(color.Italic).SprintFunc() // BoldGreen applies bold green color to output. BoldGreen = color.New(color.FgGreen, color.Bold).SprintFunc() // BoldRed applies bold red color to output. BoldRed = color.New(color.FgRed, color.Bold).SprintFunc() // BoldYellow applies bold yellow color to output. BoldYellow = color.New(color.FgYellow, color.Bold).SprintFunc() // BoldBlue applies bold blue color to output. BoldBlue = color.New(color.FgBlue, color.Bold).SprintFunc() )
var ( // ErrCommandNotFound is returned when a command is not found. ErrCommandNotFound = errors.New("command not found") // ErrFlagRequired is returned when a required flag is missing. ErrFlagRequired = errors.New("required flag missing") // ErrFlagInvalid is returned when a flag value is invalid. ErrFlagInvalid = errors.New("invalid flag value") // ErrInvalidArguments is returned when arguments are invalid. ErrInvalidArguments = errors.New("invalid arguments") // ErrPluginNotFound is returned when a plugin is not found. ErrPluginNotFound = errors.New("plugin not found") // ErrPluginAlreadyRegistered is returned when trying to register a duplicate plugin. ErrPluginAlreadyRegistered = errors.New("plugin already registered") // ErrCircularDependency is returned when plugins have circular dependencies. ErrCircularDependency = errors.New("circular plugin dependency detected") )
Functions ¶
func AppFromContext ¶
func AppFromContext(ctx CommandContext) (forge.App, bool)
AppFromContext retrieves the Forge app from a command context.
func ConfigureColors ¶
func ConfigureColors(config ColorConfig)
ConfigureColors configures the global color settings.
func FormatError ¶
FormatError formats an error for display.
func GenerateBashCompletion ¶
GenerateBashCompletion generates bash completion script.
func GenerateFishCompletion ¶
GenerateFishCompletion generates fish completion script.
func GenerateZshCompletion ¶
GenerateZshCompletion generates zsh completion script.
func GetExitCode ¶
GetExitCode extracts the exit code from an error.
func GetService ¶
func GetService[T any](ctx CommandContext) (T, error)
GetService retrieves a service from the Forge app via DI.
func MultiSelectAsync ¶
MultiSelectAsync prompts for multiple selections with async-loaded options Shows a spinner while loading options.
func MultiSelectWithProgressFeedback ¶
func MultiSelectWithProgressFeedback(ctx context.Context, question string, loader ProgressLoader) ([]string, error)
MultiSelectWithProgressFeedback prompts for multiple selections with progress feedback.
func MultiSelectWithRetry ¶
func MultiSelectWithRetry(ctx context.Context, question string, loader OptionsLoader, maxRetries int) ([]string, error)
MultiSelectWithRetry prompts for multiple selections with retry on failure.
func MustGetApp ¶
func MustGetApp(ctx CommandContext) forge.App
MustGetApp retrieves the Forge app from context or panics.
func MustGetService ¶
func MustGetService[T any](ctx CommandContext) T
MustGetService retrieves a service from the Forge app or panics.
func PromptPassword ¶
PromptPassword prompts for a password (hidden input).
func PromptWithDefault ¶
PromptWithDefault prompts with a default value.
func RunApp ¶ added in v0.10.0
func RunApp(setup AppSetup, opts ...RunAppOption)
RunApp wraps a lazily-created Forge app in a CLI application and runs it. This is the primary entry point for CLI-wrapped Forge applications.
The setup closure receives parsed CLI flags so CLI arguments can drive app configuration (e.g., port, environment, DSN).
Default behavior:
- No args: runs the forge app via app.Run() (same as "serve")
- "serve" / "start" / "run": starts the forge app
- "migrate up": runs pending migrations from all MigratableExtension
- "migrate down": rolls back the last batch of migrations
- "migrate status": shows migration status
- "info": shows app information
- "health": checks app health
- "extensions": lists registered extensions
Example:
func main() {
cli.RunApp(func(ctx cli.CommandContext) (forge.App, error) {
return forge.New(
forge.WithAppName("my-app"),
forge.WithHTTPAddress(":"+ctx.String("port")),
), nil
},
cli.WithGlobalFlags(cli.NewStringFlag("port", "p", "HTTP port", "8080")),
cli.WithAutoMigrate(),
)
}
func SelectAsync ¶
SelectAsync prompts for selection with async-loaded options Shows a spinner while loading options.
func SelectWithProgressFeedback ¶
func SelectWithProgressFeedback(ctx context.Context, question string, loader ProgressLoader) (string, error)
SelectWithProgressFeedback prompts with detailed progress feedback.
func SelectWithRetry ¶
func SelectWithRetry(ctx context.Context, question string, loader OptionsLoader, maxRetries int) (string, error)
SelectWithRetry prompts for selection with retry on failure Useful for loading from flaky sources.
Types ¶
type AppRunner ¶ added in v1.4.5
type AppRunner struct {
// contains filtered or unexported fields
}
AppRunner wraps a lazily-created Forge app in a production-ready CLI. Use NewAppRunner to create an instance, then configure with method chaining or use RunApp for a variadic-options style.
func NewAppRunner ¶ added in v1.4.5
NewAppRunner creates a new AppRunner with the given setup closure. The setup closure receives parsed CLI flags and creates the Forge app.
Example:
cli.NewAppRunner(func(ctx cli.CommandContext) (forge.App, error) {
return forge.New(
forge.WithAppName("my-app"),
forge.WithHTTPAddress(":"+ctx.String("port")),
), nil
}).
Name("my-app").
AutoMigrate().
WithGlobalFlags(cli.NewStringFlag("port", "p", "HTTP port", "8080")).
Run()
func (*AppRunner) AutoMigrate ¶ added in v1.4.5
AutoMigrate enables running pending migrations before the app starts serving when using the serve/start command.
func (*AppRunner) Description ¶ added in v1.4.5
Description sets the CLI application description.
func (*AppRunner) DisableMigrationCommands ¶ added in v1.4.5
DisableMigrationCommands disables auto-registration of migrate commands.
func (*AppRunner) DisableServeCommand ¶ added in v1.4.5
DisableServeCommand disables the built-in serve command.
func (*AppRunner) Execute ¶ added in v1.4.5
Execute builds and runs the CLI, returning any error instead of exiting. Useful for testing.
func (*AppRunner) Run ¶ added in v1.4.5
func (r *AppRunner) Run()
Run builds the CLI, registers all commands, and executes it. This method blocks until the command completes, then exits the process.
func (*AppRunner) WithExtraCommands ¶ added in v1.4.5
WithExtraCommands adds additional commands alongside the built-in ones.
func (*AppRunner) WithGlobalFlags ¶ added in v1.4.5
WithGlobalFlags adds flags available to all commands and the setup closure. These flags are injected into every command before flag parsing.
type AppSetup ¶ added in v1.4.5
type AppSetup func(ctx CommandContext) (forge.App, error)
AppSetup creates a forge.App with access to parsed CLI flags and args. It is called once per process invocation, before the matched command executes. The returned app is available to all commands via ctx.App().
type BasePlugin ¶
type BasePlugin struct {
// contains filtered or unexported fields
}
BasePlugin provides a base implementation for plugins.
func NewBasePlugin ¶
func NewBasePlugin(name, version, description string) *BasePlugin
NewBasePlugin creates a new base plugin.
func (*BasePlugin) AddCommand ¶
func (p *BasePlugin) AddCommand(cmd Command)
AddCommand adds a command to the plugin.
func (*BasePlugin) AddDependency ¶
func (p *BasePlugin) AddDependency(dep string)
AddDependency adds a dependency to the plugin.
func (*BasePlugin) Commands ¶
func (p *BasePlugin) Commands() []Command
Commands returns the commands provided by this plugin.
func (*BasePlugin) Dependencies ¶
func (p *BasePlugin) Dependencies() []string
Dependencies returns the plugin dependencies.
func (*BasePlugin) Description ¶
func (p *BasePlugin) Description() string
Description returns the plugin description.
func (*BasePlugin) Initialize ¶
func (p *BasePlugin) Initialize() error
Initialize is called when the plugin is registered.
func (*BasePlugin) SetCommands ¶
func (p *BasePlugin) SetCommands(commands []Command)
SetCommands sets the commands for the plugin.
func (*BasePlugin) SetDependencies ¶
func (p *BasePlugin) SetDependencies(dependencies []string)
SetDependencies sets the dependencies for the plugin.
func (*BasePlugin) Version ¶
func (p *BasePlugin) Version() string
Version returns the plugin version.
type CLI ¶
type CLI interface {
// Identity
Name() string
Version() string
Description() string
// Commands
AddCommand(cmd Command) error
Commands() []Command
Run(args []string) error
// Global flags
Flag(name string, opts ...FlagOption) Flag
// Configuration
SetOutput(w io.Writer)
SetErrorHandler(handler func(error))
// Plugin support
RegisterPlugin(plugin Plugin) error
Plugins() []Plugin
}
CLI represents a command-line application.
type CLIError ¶
CLIError represents a CLI-specific error with an exit code.
type CLILogger ¶
type CLILogger struct {
// contains filtered or unexported fields
}
CLILogger is a CLI-friendly logger with color support.
func NewCLILogger ¶
func NewCLILogger(opts ...LoggerOption) *CLILogger
NewCLILogger creates a new CLI logger.
type ColorConfig ¶
ColorConfig controls color output behavior.
func DefaultColorConfig ¶
func DefaultColorConfig() ColorConfig
DefaultColorConfig returns the default color configuration.
type Command ¶
type Command interface {
// Identity
Name() string
Description() string
Usage() string
Aliases() []string
// Execution
Run(ctx CommandContext) error
// Subcommands
AddSubcommand(cmd Command) error
Subcommands() []Command
FindSubcommand(name string) (Command, bool)
// Flags
Flags() []Flag
AddFlag(flag Flag)
// Middleware
Before(fn MiddlewareFunc) Command
After(fn MiddlewareFunc) Command
// Parent (for navigation)
SetParent(parent Command)
Parent() Command
}
Command represents a CLI command.
func NewCommand ¶
func NewCommand(name, description string, handler CommandHandler, opts ...CommandOption) Command
NewCommand creates a new command.
type CommandContext ¶
type CommandContext interface {
// Arguments
Args() []string
Arg(index int) string
NArgs() int
// Flags
Flag(name string) FlagValue
String(name string) string
Int(name string) int
Bool(name string) bool
StringSlice(name string) []string
Duration(name string) int64
// Output
Println(a ...any)
Printf(format string, a ...any)
Error(err error)
Success(msg string)
Warning(msg string)
Info(msg string)
// Input
Prompt(question string) (string, error)
Confirm(question string) (bool, error)
Select(question string, options []string) (string, error)
MultiSelect(question string, options []string) ([]string, error)
// Async Input (with spinner feedback)
SelectAsync(question string, loader OptionsLoader) (string, error)
MultiSelectAsync(question string, loader OptionsLoader) ([]string, error)
SelectWithRetry(question string, loader OptionsLoader, maxRetries int) (string, error)
MultiSelectWithRetry(question string, loader OptionsLoader, maxRetries int) ([]string, error)
// Progress
ProgressBar(total int) ProgressBar
Spinner(message string) Spinner
// Tables
Table() TableWriter
// Context
Context() context.Context
// App integration (optional, returns nil if not running with Forge app)
App() forge.App
// Command reference
Command() Command
// Logger
Logger() *CLILogger
}
CommandContext provides context to command execution.
type CommandHandler ¶
type CommandHandler func(ctx CommandContext) error
CommandHandler is a function that handles command execution.
type CommandOption ¶
type CommandOption func(*command)
CommandOption is a functional option for configuring commands.
func WithAfter ¶
func WithAfter(fn MiddlewareFunc) CommandOption
WithAfter adds an after middleware.
func WithAliases ¶
func WithAliases(aliases ...string) CommandOption
WithAliases sets command aliases.
func WithBefore ¶
func WithBefore(fn MiddlewareFunc) CommandOption
WithBefore adds a before middleware.
func WithFlags ¶
func WithFlags(flags ...Flag) CommandOption
WithFlags adds multiple flags to the command.
func WithSubcommand ¶
func WithSubcommand(sub Command) CommandOption
WithSubcommand adds a subcommand.
type Config ¶
type Config struct {
Name string
Version string
Description string
Output io.Writer
ErrorHandler func(error)
Logger *CLILogger
App forge.App // Optional Forge app integration
AppProvider func(CommandContext) (forge.App, error) // Lazy app creation (mutually exclusive with App)
}
Config configures a CLI application.
type Flag ¶
type Flag interface {
Name() string
ShortName() string
Description() string
DefaultValue() any
Required() bool
Type() FlagType
Validate(value any) error
}
Flag represents a command-line flag.
func NewBoolFlag ¶
func NewBoolFlag(name, shortName, description string, defaultValue bool, opts ...FlagOption) Flag
NewBoolFlag creates a bool flag.
func NewDurationFlag ¶
func NewDurationFlag(name, shortName, description string, defaultValue time.Duration, opts ...FlagOption) Flag
NewDurationFlag creates a duration flag.
func NewFlag ¶
func NewFlag(name string, flagType FlagType, opts ...FlagOption) Flag
NewFlag creates a new flag.
func NewIntFlag ¶
func NewIntFlag(name, shortName, description string, defaultValue int, opts ...FlagOption) Flag
NewIntFlag creates an int flag.
func NewStringFlag ¶
func NewStringFlag(name, shortName, description, defaultValue string, opts ...FlagOption) Flag
NewStringFlag creates a string flag.
func NewStringSliceFlag ¶
func NewStringSliceFlag(name, shortName, description string, defaultValue []string, opts ...FlagOption) Flag
NewStringSliceFlag creates a string slice flag.
type FlagOption ¶
type FlagOption func(*flagConfig)
FlagOption is a functional option for configuring flags.
func ValidateEnum ¶
func ValidateEnum(allowed ...string) FlagOption
ValidateEnum validates that a string flag is one of the allowed values.
func ValidateRange ¶
func ValidateRange(minVal, maxVal int) FlagOption
ValidateRange validates that an int flag is within a range.
func WithAlias ¶
func WithAlias(alias string) FlagOption
WithAlias sets a short name alias for the flag.
func WithBoolFlag ¶
func WithBoolFlag(name, shortName, description string, defaultValue bool, opts ...FlagOption) FlagOption
WithBoolFlag creates a bool flag.
func WithDefault ¶
func WithDefault(value any) FlagOption
WithDefault sets a default value for the flag.
func WithDescription ¶
func WithDescription(desc string) FlagOption
WithDescription sets the description for the flag.
func WithDurationFlag ¶
func WithDurationFlag(name, shortName, description string, defaultValue time.Duration, opts ...FlagOption) FlagOption
WithDurationFlag creates a duration flag.
func WithIntFlag ¶
func WithIntFlag(name, shortName, description string, defaultValue int, opts ...FlagOption) FlagOption
WithIntFlag creates an int flag.
func WithStringFlag ¶
func WithStringFlag(name, shortName, description, defaultValue string, opts ...FlagOption) FlagOption
WithStringFlag creates a string flag.
func WithStringSliceFlag ¶
func WithStringSliceFlag(name, shortName, description string, defaultValue []string, opts ...FlagOption) FlagOption
WithStringSliceFlag creates a string slice flag.
func WithValidator ¶
func WithValidator(validator func(any) error) FlagOption
WithValidator sets a custom validator for the flag.
type FlagValue ¶
type FlagValue interface {
String() string
Int() int
Bool() bool
StringSlice() []string
Duration() time.Duration
IsSet() bool
Raw() any
}
FlagValue represents a parsed flag value.
type LoggerOption ¶
type LoggerOption func(*loggerConfig)
LoggerOption is a functional option for configuring the logger.
func WithColors ¶
func WithColors(enabled bool) LoggerOption
WithColors enables or disables colored output.
func WithPrefix ¶
func WithPrefix(prefix string) LoggerOption
WithPrefix sets a prefix for all log messages.
type MiddlewareFunc ¶
type MiddlewareFunc func(next CommandHandler) CommandHandler
MiddlewareFunc is a function that wraps a CommandHandler.
type OptionsLoader ¶
OptionsLoader is a function that loads options asynchronously.
type Plugin ¶
type Plugin interface {
// Name returns the unique name of the plugin
Name() string
// Version returns the plugin version
Version() string
// Description returns a human-readable description
Description() string
// Commands returns the commands provided by this plugin
Commands() []Command
// Dependencies returns the names of plugins this plugin depends on
Dependencies() []string
// Initialize is called when the plugin is registered
// This allows the plugin to perform setup before commands are added
Initialize() error
}
Plugin represents a CLI plugin that can provide commands.
type PluginMetadata ¶
type PluginMetadata struct {
Name string
Version string
Description string
Dependencies []string
Commands []string // Command names provided by this plugin
}
PluginMetadata contains information about a registered plugin.
type PluginRegistry ¶
type PluginRegistry struct {
// contains filtered or unexported fields
}
PluginRegistry manages CLI plugins.
func NewPluginRegistry ¶
func NewPluginRegistry() *PluginRegistry
NewPluginRegistry creates a new plugin registry.
func (*PluginRegistry) All ¶
func (r *PluginRegistry) All() []Plugin
All returns all registered plugins.
func (*PluginRegistry) Count ¶
func (r *PluginRegistry) Count() int
Count returns the number of registered plugins.
func (*PluginRegistry) Get ¶
func (r *PluginRegistry) Get(name string) (Plugin, error)
Get retrieves a plugin by name.
func (*PluginRegistry) GetMetadata ¶
func (r *PluginRegistry) GetMetadata(name string) (*PluginMetadata, error)
GetMetadata returns metadata for a specific plugin.
func (*PluginRegistry) Has ¶
func (r *PluginRegistry) Has(name string) bool
Has checks if a plugin exists.
func (*PluginRegistry) Metadata ¶
func (r *PluginRegistry) Metadata() []*PluginMetadata
Metadata returns metadata for all plugins.
func (*PluginRegistry) Names ¶
func (r *PluginRegistry) Names() []string
Names returns the names of all registered plugins sorted alphabetically.
func (*PluginRegistry) Register ¶
func (r *PluginRegistry) Register(plugin Plugin) error
Register registers a plugin.
func (*PluginRegistry) RegisterAll ¶
func (r *PluginRegistry) RegisterAll(plugins []Plugin) error
RegisterAll registers multiple plugins with dependency resolution.
type ProgressBar ¶
ProgressBar displays a progress bar.
type ProgressLoader ¶
type ProgressLoader func(ctx context.Context, progress func(current, total int, message string)) ([]string, error)
ProgressLoader prompts for selection with progress feedback. Useful when loading takes multiple steps.
type RunAppOption ¶ added in v0.10.0
type RunAppOption func(*AppRunner)
RunAppOption is a functional option for configuring an AppRunner via RunApp.
func WithAutoMigrate ¶ added in v0.10.0
func WithAutoMigrate() RunAppOption
WithAutoMigrate enables running pending migrations before the app starts serving when using the serve/start command.
func WithCLIDescription ¶ added in v0.10.0
func WithCLIDescription(description string) RunAppOption
WithCLIDescription overrides the CLI application description.
func WithCLIName ¶ added in v0.10.0
func WithCLIName(name string) RunAppOption
WithCLIName overrides the CLI application name.
func WithCLIVersion ¶ added in v0.10.0
func WithCLIVersion(version string) RunAppOption
WithCLIVersion overrides the CLI application version.
func WithDisableMigrationCommands ¶ added in v0.10.0
func WithDisableMigrationCommands() RunAppOption
WithDisableMigrationCommands disables auto-registration of migrate commands.
func WithDisableServeCommand ¶ added in v0.10.0
func WithDisableServeCommand() RunAppOption
WithDisableServeCommand disables the auto-registered serve command.
func WithExtraCommands ¶ added in v0.10.0
func WithExtraCommands(cmds ...Command) RunAppOption
WithExtraCommands adds additional commands to the CLI wrapper.
func WithGlobalFlags ¶ added in v1.4.5
func WithGlobalFlags(flags ...Flag) RunAppOption
WithGlobalFlags adds flags available to all commands and the setup closure.
type TableAlignment ¶
type TableAlignment int
TableAlignment defines column alignment.
const ( AlignLeft TableAlignment = iota AlignCenter AlignRight )
type TableStyle ¶
type TableStyle int
TableStyle defines the table border style.
const ( StyleDefault TableStyle = iota StyleRounded StyleSimple StyleCompact StyleMarkdown )
type TableWriter ¶
type TableWriter interface {
SetHeader(headers []string)
AppendRow(row []string)
SetAlignment(alignment TableAlignment)
SetColumnAlignment(column int, alignment TableAlignment)
SetStyle(style TableStyle)
SetMaxColumnWidth(width int)
SetMinColumnWidth(width int)
Render()
}
TableWriter provides table formatting.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
async_select
command
|
|
|
enhanced_features
command
|
|
|
forge_integration
command
|
|
|
interactive
command
|
|
|
interactive_arrows
command
|
|
|
plugin
command
|
|
|
simple
command
|
|
|
subcommands
command
|