Documentation
¶
Overview ¶
Package cli implements the Artisan-style command-line interface. The CLI is a thin, embeddable layer: callers in cmd/artisan (or in their own applications) construct a *cli.App, register their drivers/migrations/ seeders, and call App.Execute().
The CLI is decoupled from any specific driver: applications are responsible for blank-importing the driver they need before calling Execute().
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type App ¶
type App struct {
Root *cobra.Command
Manager *database.Manager
Migrations *migrations.Registry
Seeders *seeder.Registry
Logger *logger.Logger
Connector func(*App) (*database.Connection, error)
ProjectName string
}
App ties together a database manager, migration registry, seeder registry and Cobra root command. Applications usually take the default App via Default() and add custom commands.
func New ¶
New constructs an App with the given options. Nil fields fall back to process-wide defaults so a vanilla `lagocli` binary just works.
func (*App) AddCommand ¶
AddCommand mounts a command directly on the root.
func (*App) Connection ¶
func (a *App) Connection() (*database.Connection, error)
Connection resolves the active database connection via the configured connector. It is the entry point every db-touching command uses.
type Options ¶
type Options struct {
ProjectName string
Manager *database.Manager
Migrations *migrations.Registry
Seeders *seeder.Registry
Logger *logger.Logger
// Connector lets the host application override how the active connection
// is resolved. The default resolves it from environment variables.
Connector func(*App) (*database.Connection, error)
}
Options configures a fresh App.