cli

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AfterCommand

func AfterCommand(fn func(ctx *Context, duration time.Duration, err error))

AfterCommand registers a hook invoked after any Nimbus CLI command runs. This is used by observability tooling (e.g. Telescope) without coupling the cli package to those plugins.

func RegisterCommand

func RegisterCommand(c Command)

RegisterCommand adds a command to the global CLI registry. Framework code and user applications can call this from init() to auto-register commands before the root executes.

func RegisterRootAttach

func RegisterRootAttach(fn RootAttach)

RegisterRootAttach registers a function that attaches nested commands to the CLI root. Called once during Execute, after all RegisterCommand hooks.

func Timestamp

func Timestamp() string

Timestamp returns a standard migration-style timestamp format.

func ToPascal

func ToPascal(snake string) string

ToPascal converts a string from snake_case to PascalCase.

func ToSnake

func ToSnake(s string) string

ToSnake converts a string to snake_case.

Types

type Command

type Command interface {
	Name() string
	Description() string
	Run(ctx *Context) error
}

Command represents a high-level Nimbus CLI command (Artisan-style).

type CommandWithAliases

type CommandWithAliases interface {
	Command
	Aliases() []string
}

CommandWithAliases allows a command to define aliases.

type CommandWithArgs

type CommandWithArgs interface {
	Command
	Args() int // Returns the exact number of required arguments, or -1 for any
}

CommandWithArgs allows a command to specify required positional arguments.

type CommandWithFlags

type CommandWithFlags interface {
	Command
	Flags(cmd *cobra.Command)
}

CommandWithFlags allows a command to define its own flags.

type Context

type Context struct {
	Cmd     *cobra.Command
	Args    []string
	AppRoot string
	Stdout  io.Writer
	Stderr  io.Writer
	Stdin   io.Reader
	UI      *ui.UI
}

Context provides per-command information and helpers, similar to Laravel Artisan's Command context. It wraps Cobra's command and args and adds app root discovery and a UI helper.

func NewContext

func NewContext(cmd *cobra.Command, args []string) *Context

NewContext builds a Context for a running Cobra command.

type Root

type Root struct {
	*cobra.Command
}

Root wraps the Cobra root command for the Nimbus CLI.

func NewRoot

func NewRoot(root *cobra.Command) *Root

NewRoot constructs a new Root from an existing Cobra root command. It is intended to be called from cmd/nimbus/main.go with the rootCmd defined there, so that the cli package can attach additional behavior (like auto-registered commands) before executing.

func (*Root) Execute

func (r *Root) Execute() error

Execute attaches all registered commands to the given root and runs it.

type RootAttach

type RootAttach func(root *cobra.Command)

RootAttach is called after flat commands are registered; use it to add nested commands (e.g. `nimbus plugin install` under `nimbus plugin`).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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