cli

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 15 Imported by: 0

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

func Stubs

func Stubs() fs.FS

Stubs returns the embedded stub filesystem rooted at "stubs/". The CLI command implementations read from this FS by default; applications can override individual stubs via cmd.SetStubOverride().

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 Default

func Default() *App

Default is the zero-config App most binaries use.

func New

func New(opts Options) *App

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

func (a *App) AddCommand(c *cobra.Command)

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.

func (*App) Execute

func (a *App) Execute()

Execute is a convenience wrapper around App.Root.Execute() that prints errors in red and exits with status 1 on failure.

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.

Directories

Path Synopsis
Package cmd contains the implementation of each Artisan subcommand.
Package cmd contains the implementation of each Artisan subcommand.

Jump to

Keyboard shortcuts

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