commands

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package commands provides the CLI command implementations for mink.

Package commands provides the CLI command implementations for mink.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Version information (set at build time)
	Version   = "dev"
	Commit    = "none"
	BuildDate = "unknown"
)

Functions

func Execute

func Execute() error

Execute runs the root command

func NewDiagnoseCommand

func NewDiagnoseCommand() *cobra.Command

NewDiagnoseCommand creates the diagnose command

func NewGenerateCommand

func NewGenerateCommand() *cobra.Command

NewGenerateCommand creates the generate command

func NewInitCommand

func NewInitCommand() *cobra.Command

NewInitCommand creates the init command

func NewMigrateCommand

func NewMigrateCommand() *cobra.Command

NewMigrateCommand creates the migrate command

func NewProjectionCommand

func NewProjectionCommand() *cobra.Command

NewProjectionCommand creates the projection command

func NewRootCommand

func NewRootCommand() *cobra.Command

NewRootCommand creates the root command for the mink CLI

func NewSchemaCommand

func NewSchemaCommand() *cobra.Command

NewSchemaCommand creates the schema command

func NewStreamCommand

func NewStreamCommand() *cobra.Command

NewStreamCommand creates the stream command

func NewVersionCommand

func NewVersionCommand(version, commit, date string) *cobra.Command

NewVersionCommand creates the version command

func SetupDiagnosticEnv

func SetupDiagnosticEnv(ctx context.Context) (*DiagnosticEnv, DiagnosticSkipReason, error)

SetupDiagnosticEnv creates a DiagnosticEnv for diagnostic checks. Returns (env, skipReason, error). If skipReason != DiagnosticNotSkipped, the check should be skipped.

func Splash

func Splash()

Splash shows a quick loading animation

Types

type AdapterFactory

type AdapterFactory struct {
	// contains filtered or unexported fields
}

AdapterFactory creates the appropriate adapter based on configuration.

func NewAdapterFactory

func NewAdapterFactory(cfg *config.Config) (*AdapterFactory, error)

NewAdapterFactory creates a new adapter factory.

func (*AdapterFactory) CreateAdapter

func (f *AdapterFactory) CreateAdapter(ctx context.Context) (CLIAdapter, error)

CreateAdapter creates the appropriate adapter based on the driver configuration. For PostgreSQL, it validates the connection with a short timeout to fail fast on invalid URLs.

func (*AdapterFactory) GetDatabaseURL

func (f *AdapterFactory) GetDatabaseURL() string

GetDatabaseURL returns the resolved database URL.

func (*AdapterFactory) IsMemoryDriver

func (f *AdapterFactory) IsMemoryDriver() bool

IsMemoryDriver returns true if using the memory driver.

type AggregateData

type AggregateData struct {
	Name    string
	Module  string
	Package string
	Events  []EventData
}

type AnimatedVersionModel

type AnimatedVersionModel struct {
	// contains filtered or unexported fields
}

AnimatedVersion shows an animated version display

func NewAnimatedVersion

func NewAnimatedVersion(version string) AnimatedVersionModel

func (AnimatedVersionModel) Init

func (m AnimatedVersionModel) Init() tea.Cmd

func (AnimatedVersionModel) Update

func (m AnimatedVersionModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (AnimatedVersionModel) View

func (m AnimatedVersionModel) View() string

type CLIAdapter

CLIAdapter combines all adapter interfaces needed by CLI commands.

type CheckResult

type CheckResult struct {
	Name           string
	Status         CheckStatus
	Message        string
	Recommendation string
}

CheckResult represents the result of a diagnostic check

type CheckStatus

type CheckStatus int

CheckStatus represents the status of a diagnostic check

const (
	StatusOK CheckStatus = iota
	StatusWarning
	StatusError
)

type CommandData

type CommandData struct {
	Module    string
	Package   string
	Name      string
	Aggregate string
}

type DiagnosticCheck

type DiagnosticCheck struct {
	Name  string
	Check func() CheckResult
}

DiagnosticCheck represents a diagnostic check function

type DiagnosticEnv

type DiagnosticEnv struct {
	Adapter CLIAdapter
	Config  *config.Config
	// contains filtered or unexported fields
}

DiagnosticEnv holds the environment for diagnostic checks that need database access. This consolidates the repeated pattern of checking config, memory driver, and DB URL.

func (*DiagnosticEnv) Close

func (e *DiagnosticEnv) Close()

Close cleans up the DiagnosticEnv resources.

type DiagnosticSkipReason

type DiagnosticSkipReason int

DiagnosticSkipReason represents why a diagnostic check was skipped.

const (
	// DiagnosticNotSkipped means the diagnostic should proceed.
	DiagnosticNotSkipped DiagnosticSkipReason = iota
	// DiagnosticSkipNoConfig means no configuration was found.
	DiagnosticSkipNoConfig
	// DiagnosticSkipMemoryDriver means the memory driver is being used.
	DiagnosticSkipMemoryDriver
	// DiagnosticSkipNoDBURL means the database URL is not set.
	DiagnosticSkipNoDBURL
)

type EventData

type EventData struct {
	Name          string
	AggregateName string
}

type EventFileData

type EventFileData struct {
	Module    string
	Package   string
	Aggregate string
	Events    []EventData
}

type Migration

type Migration struct {
	Name string
	Path string
}

Migration represents a migration file

type MigrationEnv

type MigrationEnv struct {
	Adapter       CLIAdapter
	Config        *config.Config
	Cwd           string
	MigrationsDir string
	// contains filtered or unexported fields
}

MigrationEnv holds the environment for migration-related commands. This consolidates the repeated pattern of loading config, checking for memory driver, and creating the adapter used across migrate up/down/status commands.

func SetupMigrationEnv

func SetupMigrationEnv(ctx context.Context) (*MigrationEnv, bool, error)

SetupMigrationEnv creates a MigrationEnv for migration commands. Returns (env, isMemory, error). If isMemory is true, migrations are not needed.

func (*MigrationEnv) Close

func (e *MigrationEnv) Close()

Close cleans up the MigrationEnv resources.

type ProjectionData

type ProjectionData struct {
	Module  string
	Package string
	Name    string
	Events  []string
}

type SingleEventData

type SingleEventData struct {
	Module    string
	Package   string
	Name      string
	Aggregate string
}

type StreamEvent

type StreamEvent struct {
	ID        string    `json:"id"`
	StreamID  string    `json:"stream_id"`
	Version   int64     `json:"version"`
	Type      string    `json:"type"`
	Data      string    `json:"data"`
	Metadata  string    `json:"metadata,omitempty"`
	Timestamp time.Time `json:"timestamp"`
}

StreamEvent represents an event in a stream (for export)

Jump to

Keyboard shortcuts

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