launcher

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: Apache-2.0, MIT Imports: 37 Imported by: 0

Documentation

Overview

package launcher implements the application command line.

Grammar is declared once as a struct (kong); config is layered separately by internal/config. Kong flags stay zero-valued.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunCLI

func RunCLI(args []string, opts ...kong.Option) error

RunCLI parses args and runs the selected command, including variant-specific db commands.

Types

type CLI

type CLI struct {
	// Global CLI args
	EnvFile string           `help:"Load environment variables from a dotenv file (default: .env.local when present)"`
	DataDir string           `name:"data-dir" help:"Application data directory for on-disk runtime state"`
	Version kong.VersionFlag `short:"V" help:"Show the application version"`

	// CLI subcommands
	Serve   ServeCmd   `cmd:"" help:"Start the application server"`
	DB      DBCmd      `cmd:"" help:"Database backup, restore, and migration commands"`
	Secrets SecretsCmd `cmd:"" help:"Generate application secrets"`
	Setup   SetupCmd   `cmd:"" help:"Bootstrap the first admin account (fresh database only)"`
	Health  HealthCmd  `cmd:"" help:"Check application health" aliases:"hc"`
}

CLI is Kong's command-line grammar.

type DBCmd

type DBCmd struct {
	MigrateUp      MigrateUpCmd      `cmd:"" name:"migrate:up" help:"Run database migrations"`
	MigrateDown    MigrateDownCmd    `cmd:"" name:"migrate:down" help:"Rollback the most recent migration"`
	MigrateStatus  MigrateStatusCmd  `cmd:"" name:"migrate:status" help:"Check database migration status"`
	MigrateVersion MigrateVersionCmd `cmd:"" name:"migrate:version" help:"Print the current migration version"`
	Export         DBExportCmd       `cmd:"" help:"Export schema & data or data only (SQL format)"`
	Import         DBImportCmd       `cmd:"" help:"Import from a SQL file"`
	Dump           DBDumpCmd         `cmd:"" help:"Dump schema & data or data only (custom format)"`
	Restore        DBRestoreCmd      `cmd:"" help:"Restore from a dump file (custom format)"`
}

DBCmd exposes the release manage surface; migration maintenance commands are debug-only.

type DBDumpCmd

type DBDumpCmd struct {
	Mode string `arg:"" help:"Dump scope: all (schema & data) or data"`
}

func (*DBDumpCmd) Run

func (c *DBDumpCmd) Run(cli *CLI) error

type DBExportCmd

type DBExportCmd struct {
	Mode string `arg:"" help:"Export scope: all (schema & data) or data"`
}

func (*DBExportCmd) Run

func (c *DBExportCmd) Run(cli *CLI) error

type DBImportCmd

type DBImportCmd struct {
	File   string `arg:"" help:"Path to the .sql file"`
	Force  bool   `help:"Skip the confirmation prompt"`
	DryRun bool   `help:"Print the psql command without running it"`
}

func (*DBImportCmd) Run

func (c *DBImportCmd) Run(cli *CLI) error

type DBRestoreCmd

type DBRestoreCmd struct {
	Mode   string `arg:"" help:"Restore scope: all, data, or schema"`
	File   string `arg:"" help:"Path to the .dump file"`
	Force  bool   `help:"Skip the confirmation prompt"`
	DryRun bool   `help:"Print the pg_restore command without running it"`
}

func (*DBRestoreCmd) Run

func (c *DBRestoreCmd) Run(cli *CLI) error

type HealthCmd

type HealthCmd struct {
	Addr string `help:"Server health endpoint URL (default: from config)"`
	Live bool   `help:"Check live server via HTTP"`
}

HealthCmd checks static health or probes a live server.

func (*HealthCmd) Run

func (h *HealthCmd) Run(cli *CLI) error

type MigrateDownCmd

type MigrateDownCmd struct {
	// Count rolls back this many migrations (default 1).
	Count  int  `help:"Number of migrations to roll back (default: 1)"`
	Force  bool `help:"Skip the confirmation prompt"`
	DryRun bool `help:"Print what would be rolled back without changing anything"`
}

func (*MigrateDownCmd) Run

func (c *MigrateDownCmd) Run(cli *CLI) error

type MigrateStatusCmd

type MigrateStatusCmd struct{}

func (*MigrateStatusCmd) Run

func (c *MigrateStatusCmd) Run(cli *CLI) error

type MigrateUpCmd

type MigrateUpCmd struct {
	// To applies up to this version (inclusive); 0 means all.
	To int64 `help:"Apply migrations only up to this version (default: all)"`
}

func (*MigrateUpCmd) Run

func (c *MigrateUpCmd) Run(cli *CLI) error

type MigrateVersionCmd

type MigrateVersionCmd struct{}

func (*MigrateVersionCmd) Run

func (c *MigrateVersionCmd) Run(cli *CLI) error

type SecretsCmd

type SecretsCmd struct {
	// Apply writes to this env file; it is distinct from global --env-file.
	Apply   bool   `help:"Update the env file with new secrets"`
	RSA     bool   `help:"Generate JWT keys using RSA algorithm (2048-bit)"`
	MLDSA   bool   `help:"Generate post-quantum ML-DSA-87 JWT keys (FIPS 204)"`
	OutFile string `name:"out" default:".env.local" help:"Env file to update when using --apply"`
}

func (*SecretsCmd) Help

func (s *SecretsCmd) Help() string

func (*SecretsCmd) Run

func (s *SecretsCmd) Run(cli *CLI) error

type ServeCmd

type ServeCmd struct {
	Host string `help:"Host to bind to"`
	Port string `help:"Port to bind to"`
}

func (*ServeCmd) Run

func (s *ServeCmd) Run(cli *CLI) error

Run starts the server and shuts it down on signal.

type SetupCmd

type SetupCmd struct {
	AdminEmail    string `help:"Email address for the admin account"`
	AdminPassword string `help:"Password for the admin account (omit to be prompted, hidden input)"`
	Username      string `default:"admin" help:"Username for the admin account"`
}

SetupCmd bootstraps the first admin account. Only valid on a fresh database; refused otherwise.

func (*SetupCmd) Help

func (c *SetupCmd) Help() string

func (*SetupCmd) Run

func (c *SetupCmd) Run(cli *CLI) error

Jump to

Keyboard shortcuts

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