Skip to Content
CLICLI Commands Reference

CLI Commands Reference

The GoFrame CLI provides a comprehensive set of commands organized into logical groups. All commands must be run from within your GoFrame project directory.

Database Commands (db)

Migrations

  • db migrate - Run pending migrations
  • db rollback - Rollback the last migration
  • db clean - Drop all tables and reset database

Seeds

  • db seeds up - Run unapplied seeds
  • db seeds show - List applied seeds

Generate Commands (generate)

Application Components

  • generate handler <name> [services...] - Create HTTP request handlers
  • generate service <name> [--with-repo] - Generate service layer components
  • generate route <handler> <method> - Add route methods to existing handlers
  • generate mailer <name> <action> - Create mailer components
  • generate migration <name> [--sql] - Generate database migration files
  • generate seed <name> [--sql] - Generate database seed files
  • generate task <name> - Create task files
  • generate url-helper - Generate URL helper functions for routes
  • generate client - Generate TypeScript client from handlers

Worker Commands

  • generate worker workflow <name> [activities...] - Create Temporal workflows
  • generate worker activity <name> - Create Temporal activities

Modules

  • generate module auth - Generate authentication module

Development Commands

Routes

  • routes - List all application routes and their handlers

Tasks

  • task - Execute custom tasks (extensible)

Internationalization

  • i18n - Manage translation files and internationalization

Synchronization

  • sync - Synchronization operations

Refactoring

  • refactor - Code refactoring utilities

Extending the CLI

The root command is built with helpers from rootcmd. Use option functions to register additional commands or provide dependencies.

cmd/cli/main.go
cmdRoot := rootcmd.NewCmdRoot( rootcmd.WithCommand("task", customCmd()), rootcmd.WithMigrations(migrations), rootcmd.WithSeeds(seeds), rootcmd.WithDB(dbConnector), rootcmd.WithFxOptions(fx.Provide(NewThing)), rootcmd.WithConfig(config), )

Extension Options

  • WithCommand(namespace, cmd) - Groups your command under a namespace
  • WithMigrations(migrations) - Registers database migrations
  • WithSeeds(seeds) - Registers database seeds
  • WithDB(connector) - Provides database connection
  • WithFxOptions(opts) - Adds dependency injection options
  • WithConfig(config) - Sets application configuration

Tasks generated by generate task are automatically added to the task namespace.

Last updated on