Skip to Content
Documentation

Goofer ORM CLI Commands

This page provides an overview of all available commands in the Goofer ORM CLI. For more detailed information about specific command groups, see their dedicated pages.

Command Structure

The Goofer ORM CLI uses a hierarchical command structure:

goofer [command] [subcommand] [options]

Where:

  • command is the main command group (e.g., migrate, generate)
  • subcommand is a specific action within that group (e.g., migrate up, generate entity)
  • options are flags and arguments that modify the command’s behavior

Global Options

These options can be used with any command:

OptionDescription
--help, -hShow help for a command
--version, -vShow the CLI version
--verboseEnable verbose output
--config, -cSpecify a config file (default: ./goofer.yaml)

Available Commands

Root Commands

CommandDescription
goofer versionShow the CLI version
goofer helpShow help for a command
goofer initInitialize a new Goofer ORM project
goofer completionGenerate shell completion scripts

Migration Commands

CommandDescription
goofer migrate create <name>Create a new migration
goofer migrate upApply pending migrations
goofer migrate downRevert the last migration
goofer migrate statusShow migration status
goofer migrate resetRevert all migrations

See Migration Commands for more details.

Generate Commands

CommandDescription
goofer generate entity <name>Generate a new entity
goofer generate repository <entity>Generate a repository for an entity
goofer generate migrationGenerate a migration from entity definitions
goofer generate allGenerate all artifacts for an entity

See Generate Commands for more details.

Configuration Commands

CommandDescription
goofer config initInitialize a new configuration file
goofer config showShow the current configuration
goofer config set <key> <value>Set a configuration value

See Configuration for more details.

Command Examples

Initialize a New Project

# Initialize a new project with default settings goofer init my-project # Initialize with a specific database goofer init my-project --db postgres # Initialize with a specific directory structure goofer init my-project --template standard

Working with Migrations

# Create a new migration goofer migrate create create_users_table # Apply pending migrations goofer migrate up # Apply a specific number of migrations goofer migrate up --steps 2 # Revert the last migration goofer migrate down # Show migration status goofer migrate status

Generating Code

# Generate a User entity goofer generate entity User --fields "id:uint:primaryKey,autoIncrement name:string:notnull email:string:unique,notnull" # Generate a repository for the User entity goofer generate repository User # Generate a migration from entity definitions goofer generate migration initial_schema # Generate all artifacts for an entity goofer generate all User

Configuration Management

# Initialize a new configuration file goofer config init # Show the current configuration goofer config show # Set a configuration value goofer config set database.dialect postgres

Command Help

You can get help for any command by using the --help flag:

# Get general help goofer --help # Get help for a specific command goofer migrate --help # Get help for a specific subcommand goofer migrate create --help

The help output includes:

  • Command description
  • Usage syntax
  • Available options
  • Examples

Command Aliases

Some commands have aliases for convenience:

CommandAlias
goofer migrategoofer m
goofer generategoofer g
goofer versiongoofer v
goofer helpgoofer h

For example, you can use goofer m up instead of goofer migrate up.

Exit Codes

The CLI uses the following exit codes:

CodeMeaning
0Success
1General error
2Command-line parsing error
3Configuration error
4Database error
5Migration error
6Generation error

You can use these exit codes in scripts to check if a command succeeded or failed.

Environment Variables

The CLI supports the following environment variables:

VariableDescription
GOOFER_CONFIGPath to the configuration file
GOOFER_DATABASE_URLDatabase connection URL
GOOFER_VERBOSEEnable verbose output (set to “true”)

Environment variables take precedence over configuration file values.

Next Steps

Last updated on