Documentation
¶
Overview ¶
Purpose: This file implements the `make:migration` and `make:controller` CLI code generation commands.
Philosophy: A framework should automate boilerplate generation. Generating code programmatically using structured templates prevents typos, speeds up development, and maintains cohesive coding standards. Templates are formatted using Go's official AST formatter.
Architecture: Implements console.Command. Both commands use text/template + go/format to produce syntactically valid Go source files.
Implementation: - MakeMigrationCommand: scaffolds a self-registering migration file under database/migrations/. - MakeControllerCommand: scaffolds an HTTP controller stub under internal/controller/.
Purpose: This file implements the `migrate` and `migrate:rollback` CLI commands.
Philosophy: Database updates should be simple, single-command operations. By exposing these routines to the CLI, developers can update or revert database schemas quickly.
Architecture: Implements console.Command. Resolves the database adapter from the global gostack.DB instance.
Implementation: - MigrateCommand: triggers database.Migrator.Run() to run all pending migrations. - RollbackCommand: triggers database.Migrator.Rollback() to revert the latest migration.
Purpose: This file defines the Gost CLI console execution subsystem for the GoStack framework. It provides the Command interface and the central console Kernel that registers, dispatches, and executes CLI commands.
Philosophy: We believe CLI engines in compiled languages should remain simple, modular, and fast. By avoiding bloated runtime parsing libraries, we keep the framework's build speeds instantaneous and ensure the console runner remains compile-time verifiable.
Architecture: This console subsystem serves as the entrypoint for CLI operations. The console Kernel manages a static map of registered Commands. It acts as the routing multiplexer for incoming OS terminal arguments.
Choice: We chose a direct subcommand-to-handler router over feature-heavy external libraries (like Cobra or Urfave/CLI) to maintain a zero-dependency, minimal binary footprint and maximize compilation speed.
Implementation: - Command: An interface that commands must implement to expose their Name, Description, and Execute logic. - Kernel: The central execution coordinator.
- NewKernel(): constructor.
- Register(cmd Command): Registers command structs.
- Run(args []string): Extracts the subcommand, checks for help commands, and dispatches to the correct handler.
- printHelp(): Standard help instructions detailing available commands.
Index ¶
- type AddComponentCommand
- type Command
- type ComponentInfo
- type ComponentRegistry
- type Kernel
- type MakeAuthCommand
- type MakeControllerCommand
- type MakeMailCommand
- type MakeMiddlewareCommand
- type MakeMigrationCommand
- type MakeModelCommand
- type MakeRequestCommand
- type MakeSeederCommand
- type MigrateCommand
- type NewCommand
- type PreviewCommand
- type RollbackCommand
- type SeedCommand
- type ServeCommand
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddComponentCommand ¶
type AddComponentCommand struct{}
AddComponentCommand downloads UI components from GitHub registry.
func (*AddComponentCommand) Description ¶
func (c *AddComponentCommand) Description() string
func (*AddComponentCommand) Execute ¶
func (c *AddComponentCommand) Execute(args []string) error
Execute runs the component downloader and compilation.
func (*AddComponentCommand) Name ¶
func (c *AddComponentCommand) Name() string
type Command ¶
type Command interface {
// Name returns the trigger string (e.g. "migrate", "make:controller").
Name() string
// Description returns the help text shown in lists.
Description() string
// Execute runs the command with standard string arguments.
Execute(args []string) error
}
Command defines the structural rules that all CLI command handlers must implement.
type ComponentInfo ¶
type ComponentRegistry ¶
type ComponentRegistry struct {
Name string `json:"name"`
Version string `json:"version"`
Components map[string]ComponentInfo `json:"components"`
}
type Kernel ¶
type Kernel struct {
// contains filtered or unexported fields
}
Kernel coordinates command registration and execution.
func (*Kernel) PrintHelp ¶
func (k *Kernel) PrintHelp()
PrintHelp prints the usage instructions and list of registered commands.
type MakeAuthCommand ¶
type MakeAuthCommand struct{}
MakeAuthCommand scaffolds database tables, model logic, controller, and views for a production-ready authentication subsystem.
func (*MakeAuthCommand) Description ¶
func (c *MakeAuthCommand) Description() string
func (*MakeAuthCommand) Execute ¶
func (c *MakeAuthCommand) Execute(args []string) error
func (*MakeAuthCommand) Name ¶
func (c *MakeAuthCommand) Name() string
type MakeControllerCommand ¶
type MakeControllerCommand struct{}
MakeControllerCommand scaffolds a new HTTP controller stub under internal/controller/.
func (*MakeControllerCommand) Description ¶
func (c *MakeControllerCommand) Description() string
func (*MakeControllerCommand) Execute ¶
func (c *MakeControllerCommand) Execute(args []string) error
Execute runs the controller scaffolding pipeline.
func (*MakeControllerCommand) Name ¶
func (c *MakeControllerCommand) Name() string
type MakeMailCommand ¶
type MakeMailCommand struct{}
MakeMailCommand scaffolds a new custom email class under internal/mail/.
func (*MakeMailCommand) Description ¶
func (c *MakeMailCommand) Description() string
func (*MakeMailCommand) Execute ¶
func (c *MakeMailCommand) Execute(args []string) error
Execute runs the mail scaffolding pipeline.
func (*MakeMailCommand) Name ¶
func (c *MakeMailCommand) Name() string
type MakeMiddlewareCommand ¶
type MakeMiddlewareCommand struct{}
MakeMiddlewareCommand scaffolds a new HTTP middleware interceptor under internal/middleware/.
func (*MakeMiddlewareCommand) Description ¶
func (c *MakeMiddlewareCommand) Description() string
func (*MakeMiddlewareCommand) Execute ¶
func (c *MakeMiddlewareCommand) Execute(args []string) error
Execute runs the middleware scaffolding pipeline.
func (*MakeMiddlewareCommand) Name ¶
func (c *MakeMiddlewareCommand) Name() string
type MakeMigrationCommand ¶
type MakeMigrationCommand struct{}
MakeMigrationCommand scaffolds a new migration file under database/migrations/.
func (*MakeMigrationCommand) Description ¶
func (c *MakeMigrationCommand) Description() string
func (*MakeMigrationCommand) Execute ¶
func (c *MakeMigrationCommand) Execute(args []string) error
Execute runs the migration scaffolding pipeline.
func (*MakeMigrationCommand) Name ¶
func (c *MakeMigrationCommand) Name() string
type MakeModelCommand ¶
type MakeModelCommand struct{}
MakeModelCommand scaffolds a new typed Go model struct under internal/model/.
func (*MakeModelCommand) Description ¶
func (c *MakeModelCommand) Description() string
Description returns the human-readable help text shown in the CLI command listing.
func (*MakeModelCommand) Execute ¶
func (c *MakeModelCommand) Execute(args []string) error
Execute runs the model scaffolding pipeline.
func (*MakeModelCommand) Name ¶
func (c *MakeModelCommand) Name() string
Name returns the CLI trigger string for this command.
type MakeRequestCommand ¶
type MakeRequestCommand struct{}
MakeRequestCommand scaffolds a new request validation struct under internal/request/.
func (*MakeRequestCommand) Description ¶
func (c *MakeRequestCommand) Description() string
func (*MakeRequestCommand) Execute ¶
func (c *MakeRequestCommand) Execute(args []string) error
Execute runs the request scaffolding pipeline.
func (*MakeRequestCommand) Name ¶
func (c *MakeRequestCommand) Name() string
type MakeSeederCommand ¶
type MakeSeederCommand struct{}
MakeSeederCommand scaffolds a new database table seeder under database/seeders/.
func (*MakeSeederCommand) Description ¶
func (c *MakeSeederCommand) Description() string
func (*MakeSeederCommand) Execute ¶
func (c *MakeSeederCommand) Execute(args []string) error
Execute runs the seeder scaffolding pipeline.
func (*MakeSeederCommand) Name ¶
func (c *MakeSeederCommand) Name() string
type MigrateCommand ¶
type MigrateCommand struct{}
MigrateCommand implements the console.Command interface for the "migrate" CLI action.
func (*MigrateCommand) Description ¶
func (c *MigrateCommand) Description() string
Description returns the human-readable help text shown in the CLI command listing.
func (*MigrateCommand) Execute ¶
func (c *MigrateCommand) Execute(args []string) error
Execute runs all pending migrations against the active database connection.
func (*MigrateCommand) Name ¶
func (c *MigrateCommand) Name() string
Name returns the CLI trigger string for this command.
type NewCommand ¶
type NewCommand struct{}
NewCommand scaffolds a new GoStack project from the base GitHub repository.
func (*NewCommand) Description ¶
func (c *NewCommand) Description() string
Description returns the help text shown in lists.
func (*NewCommand) Execute ¶
func (c *NewCommand) Execute(args []string) error
Execute runs the command with standard string arguments.
type PreviewCommand ¶
type PreviewCommand struct{}
PreviewCommand spins up a local web server to display the component gallery.
func (*PreviewCommand) Description ¶
func (c *PreviewCommand) Description() string
func (*PreviewCommand) Execute ¶
func (c *PreviewCommand) Execute(args []string) error
func (*PreviewCommand) Name ¶
func (c *PreviewCommand) Name() string
type RollbackCommand ¶
type RollbackCommand struct{}
RollbackCommand implements the console.Command interface for the "migrate:rollback" CLI action.
func (*RollbackCommand) Description ¶
func (c *RollbackCommand) Description() string
Description returns the human-readable help text shown in the CLI command listing.
func (*RollbackCommand) Execute ¶
func (c *RollbackCommand) Execute(args []string) error
Execute runs the rollback operation against the active database connection.
func (*RollbackCommand) Name ¶
func (c *RollbackCommand) Name() string
Name returns the CLI trigger string for this command.
type SeedCommand ¶
type SeedCommand struct{}
SeedCommand implements the console.Command interface for the "db:seed" CLI action.
func (*SeedCommand) Description ¶
func (c *SeedCommand) Description() string
Description returns the human-readable help text shown in the CLI command listing.
func (*SeedCommand) Execute ¶
func (c *SeedCommand) Execute(args []string) error
Execute runs the seeding operation.
func (*SeedCommand) Name ¶
func (c *SeedCommand) Name() string
Name returns the CLI trigger string for this command.
type ServeCommand ¶ added in v1.0.1
type ServeCommand struct{}
ServeCommand starts the GoStack application web server.
func (*ServeCommand) Description ¶ added in v1.0.1
func (c *ServeCommand) Description() string
Description returns the help text shown in command lists.
func (*ServeCommand) Execute ¶ added in v1.0.1
func (c *ServeCommand) Execute(args []string) error
Execute runs the GoStack application server.
func (*ServeCommand) Name ¶ added in v1.0.1
func (c *ServeCommand) Name() string
Name returns the trigger string.