Saltar al contenido principal

CLI overview

The nucleus binary is the deterministic operations interface for any Nucleus project. Every command:

  • reads nucleus.yml from the current working directory by default,
  • emits structured (JSON-friendly) output where structured output makes sense,
  • exits with a non-zero status on failure and a meaningful message on stderr.

The full inventory is canonical at docs/reference/CLI_CONTRACT_MATRIX.md. The summary below groups the commands by purpose.

Project lifecycle

CommandWhat it does
nucleus new <name>Scaffold a new project (--template mvc|api).
nucleus startapp <name>Create an app scaffold inside an existing project.
nucleus serveStart the HTTP server (full-stack; add --without-defaults for a core-only boot).
nucleus healthCheck configured dependencies health.
nucleus doctorRun diagnostic checks for framework subsystems.
nucleus wizardInteractive wizard for complex commands (e.g. --type new, --type startapp, --type inspectdb).
nucleus generateGenerate model, handler, or migration scaffolds.
nucleus routesList registered HTTP routes.
nucleus testRun Go tests with project-friendly defaults.
nucleus testserverLoad fixture data and start a local server.
nucleus openapiExport the experimental OpenAPI project contract.

Database & migrations

CommandWhat it does
nucleus migrateApply pending migrations.
nucleus migrate statusShow plan vs. applied.
nucleus migrate driftDetect applied migrations whose .up.sql file is missing on disk. Exits non-zero when drift is detected (CI-friendly).
nucleus migrate downRoll back the most recent batch.
nucleus migrate steps <n>Apply exactly N migrations (subcommand of migrate, not a top-level flag).
nucleus sqlmigratePrint SQL for a named migration file without applying it.
nucleus sqlflushPrint the SQL statements that flush would execute.
nucleus sqlsequenceresetPrint SQL statements to reset table sequences/auto-increment counters.
nucleus squashmigrationsSquash a migration range into a single migration file.
nucleus optimizemigrationOptimize SQL statements in one migration file.
nucleus inspectdbInspect a live DB schema and generate Go model structs.
nucleus ogrinspectInspect geospatial tables and generate Go model structs.
nucleus seedExecute SQL seed files.
nucleus dumpdataExport DB rows as JSON fixtures.
nucleus loaddataImport JSON fixtures into DB tables.
nucleus flushDelete all data from database tables (keeps migration history).

Users & sessions

CommandWhat it does
nucleus createuserCreate or update an admin user.
nucleus changepasswordUpdate an admin user's password.
nucleus clearsessionsDelete expired or all session rows.
nucleus createcachetableCreate the SQL table used by the database-backed cache.

Inspection & settings

CommandWhat it does
nucleus routesList registered routes.
nucleus diffsettingsShow configuration differences from defaults.
nucleus config print --effectivePrint the effective merged configuration with per-key provenance (source kind + path).
nucleus shellInteractive SQL shell bound to the configured database (see below).

Effective config (nucleus config print --effective)

nucleus config print --effective prints the fully merged configuration with the source of every key, making it the primary tool for diagnosing "why is this value wrong in this environment".

# Single config file
nucleus config print --effective --config nucleus.yml

# Multiple files — merged left-to-right (defaults < file[0] < … < file[N-1])
nucleus config print --effective \
--config config/nucleus.yml \
--config config/nucleus.production.yml

# Structured JSON output
nucleus config print --effective --config nucleus.yml --json

Text output format: one line per key in key = value [source] notation. Source labels:

LabelMeaning
[default]Value comes from the framework struct default; no file or env var set it.
[yaml:path:line]Set in a YAML file at the given 1-based line number.
[yaml:path]Set in a YAML file; line could not be determined (anchor/alias or operator key).
[toml:path]Set in a TOML file (line numbers not available for TOML).
[json:path]Set in a JSON file (line numbers not available for JSON).
[env:NUCLEUS_VAR]Overridden by a NUCLEUS_-prefixed environment variable.
port = 9090 [env:NUCLEUS_PORT]
host = 0.0.0.0 [default]
databases.primary.dsn = [REDACTED] [yaml:config/nucleus.production.yml:22]
log_level = info [yaml:config/nucleus.yml:8]
  • Keys resolved entirely from framework defaults are labelled [default].
  • Secret values (DB connection strings, jwt_secret, passwords, tokens, etc.) are automatically redacted and shown as [REDACTED].
  • Environment-variable overrides appear as [env:NUCLEUS_<KEY>] and win over all file layers (the full precedence is defaults < files < env).
  • YAML file keys carry a 1-based source line when available. TOML and JSON do not expose a standard line API and always show [kind:path] with no line.

--json output is a structured document with the same fields:

{
"values": [
{ "key": "port", "value": "9090", "redacted": false, "source": { "kind": "env", "path": "NUCLEUS_PORT" } },
{ "key": "databases.primary.dsn", "value": "", "redacted": true, "source": { "kind": "yaml", "path": "config/nucleus.production.yml", "line": 22 } },
{ "key": "host", "value": "0.0.0.0", "redacted": false, "source": { "kind": "default" } }
]
}

Flags:

FlagDefaultDescription
--config <path>(none)Config file to load. Repeatable; files merge left-to-right.
--jsonfalseEmit structured JSON instead of plain-text key = value lines.

The underlying loader is exposed programmatically via pkg/nucleus.LoadEffective, which returns an EffectiveConfig whose Values []EffectiveValue carry the same Key, Value, Redacted, and Source (ConfigSource) fields.

SQL shell (nucleus shell)

nucleus shell opens an interactive SQL shell against the configured database. It does not evaluate Go expressions.

# Interactive REPL (exit with 'exit', 'quit', or '\q')
nucleus shell --config nucleus.yml

# Execute a single SQL statement and exit
nucleus shell --config nucleus.yml -c "SELECT COUNT(*) FROM users"
nucleus shell --config nucleus.yml --command "SELECT id FROM sessions LIMIT 5"

# Target a non-default database alias
nucleus shell --config nucleus.yml --database analytics

# Read-only sandbox mode — only SELECT/EXPLAIN/SHOW/DESCRIBE/VALUES allowed
nucleus shell --config nucleus.yml --sandbox

# Set a per-statement timeout (default 10s)
nucleus shell --config nucleus.yml --timeout 30s

# Pipe a SQL script via stdin
cat schema_audit.sql | nucleus shell --config nucleus.yml

Flags:

FlagDefaultDescription
--config <path>(empty)Path to the nucleus.yml config file.
--database <alias>(empty)Database alias to use; defaults to database_default.
-c / --command <sql>(empty)Execute one SQL statement and exit (non-interactive mode).
--sandboxfalseAllow only read-only statements (SELECT, EXPLAIN, SHOW, DESCRIBE, VALUES).
--timeout <duration>10sPer-statement execution timeout.

In sandbox mode the shell rejects any statement that is not a SELECT, EXPLAIN, SHOW, DESCRIBE, DESC, or VALUES prefix. This makes it safe to hand to junior operators or automation that should never mutate production data.

Mail & plugins

CommandWhat it does
nucleus mailprovidersList registered and external mail providers.
nucleus sendtestemailSend a test email through the configured mail provider.
nucleus plugin listDiscover and list plugin providers/capabilities.
nucleus plugin doctorRun health checks on configured plugins.
nucleus plugin testTest a specific plugin provider and capability.

Static assets, i18n, and content types

CommandWhat it does
nucleus collectstaticCollect static assets into configured static_root.
nucleus findstaticFind static assets across discovered source directories.
nucleus makemessagesExtract translatable strings into .po catalogs.
nucleus compilemessagesCompile .po catalogues into JSON bundles.
nucleus remove_stale_contenttypesDelete stale rows from the content types table.

Output style

Every command accepts top-level output style flags:

nucleus --output json migrate status
nucleus --output plain routes
nucleus --json diffsettings # shorthand for --output json
nucleus --color never doctor
nucleus --no-symbols health

The JSON output keys are part of the contract and pinned by contracts/cli_json_freeze_test.go.

Help

nucleus help
nucleus help migrate
nucleus migrate --help

nucleus help <command> is the canonical inline reference. The website cannot stay perfectly synchronized with every flag — when in doubt, ask the binary.

Extensions

External binaries on PATH named nucleus-<name> are automatically available as nucleus <name>. This is the plugin extension point for project-local or organization-wide commands.