command

package
v1.66.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDiffChanges = errors.New("diff contains changes")

ErrDiffChanges is returned by Diff.Run when --check is set and the diff contains executable DDL. main maps it to exit code 2. Suppressed drops alone do not trigger it.

View Source
var ErrFormatDiff = errors.New("files need formatting")

ErrFormatDiff is returned by Fmt.Run when --check is set and a file is not formatted. main maps it to exit code 2, the same as plan --check.

View Source
var ErrPlanDiff = errors.New("plan contains changes")

ErrPlanDiff is returned by Plan.Run when --check is set and the plan contains executable DDL. main maps it to exit code 2. Suppressed drops alone do not trigger it.

Functions

func StartPager added in v1.9.1

func StartPager(w io.Writer, pager *bool) (io.Writer, func(), error)

StartPager wraps w with a pager subprocess when all of the following hold:

  • paging hasn't been disabled by --no-pager (pager != nil && *pager == false),
  • either pager was explicitly forced via --pager (*pager == true) or w is a TTY (so the user is actually viewing the output interactively),
  • PISTA_PAGER is set to a non-empty command line.

pager == nil means the user passed neither --pager nor --no-pager, so the TTY check decides. Otherwise *pager explicitly turns paging on or off, but an unset PISTA_PAGER still gates everything (matching the convention that the env var is the source of truth for *which* pager to run).

Otherwise it returns w unchanged with a no-op close. The returned close function tears down the pager and waits for it to exit, so callers should always invoke it (typically via defer).

Types

type Apply

type Apply struct {
	pistachio.Options
	pistachio.ApplyOptions
}

func (*Apply) Run

func (cmd *Apply) Run(ctx context.Context, w io.Writer) error

type ApplyFrom added in v1.60.0

type ApplyFrom struct {
	pistachio.ConnOptions
	pistachio.ApplyFromOptions
}

ApplyFrom takes the connection and the flags that decide how the statements are run. Everything that decides what is read or what is run comes from the plan file, so those flags are not offered here: one given on the command line would either be ignored or turn the plan file's own scope into drift.

func (*ApplyFrom) Run added in v1.60.0

func (cmd *ApplyFrom) Run(ctx context.Context, w io.Writer) error

type Diff added in v1.54.0

type Diff struct {
	// Schemas is the one connection option diff reads. No database is opened,
	// but the parser qualifies an unqualified name with the first entry, and
	// only objects in these schemas are compared, the same way plan reads the
	// catalog.
	Schemas []string `short:"n" env:"PISTA_SCHEMAS" default:"public" help:"Schemas to compare. Unqualified names are qualified with the first."`
	pistachio.DiffOptions
	Check bool `env:"PISTA_CHECK" help:"Exit with code 2 when the diff contains executable changes."`
}

func (*Diff) AfterApply added in v1.59.0

func (cmd *Diff) AfterApply() error

AfterApply trims each schema name the way the global option does.

func (*Diff) Run added in v1.54.0

func (cmd *Diff) Run(w io.Writer) error

type Dump

type Dump struct {
	pistachio.Options
	pistachio.DumpOptions
}

func (*Dump) Run

func (cmd *Dump) Run(ctx context.Context, w io.Writer) error

type Fmt added in v0.11.0

type Fmt struct {
	Files []string `arg:"" help:"Path to the schema SQL file(s)."`
	Check bool     `` /* 131-byte string literal not displayed */
}

func (*Fmt) Run added in v0.11.0

func (cmd *Fmt) Run(w io.Writer) error

type Parse added in v1.51.0

type Parse struct {
	Files []string `arg:"" help:"Path to the schema SQL file(s)."`
	// Schemas is the one connection option parse reads. No database is opened,
	// but the parser qualifies an unqualified name with the first entry, the
	// same way plan and apply read their input.
	Schemas []string `short:"n" env:"PISTA_SCHEMAS" default:"public" help:"Schema to qualify unqualified names with. Only the first is used."`
}

func (*Parse) AfterApply added in v1.59.0

func (cmd *Parse) AfterApply() error

AfterApply trims each schema name the way the global option does.

func (*Parse) Run added in v1.51.0

func (cmd *Parse) Run(w io.Writer) error

type Plan

type Plan struct {
	pistachio.Options
	pistachio.PlanOptions
	Check bool `env:"PISTA_CHECK" help:"Exit with code 2 when the plan contains executable changes."`
}

func (*Plan) Run

func (cmd *Plan) Run(ctx context.Context, w io.Writer) error

Jump to

Keyboard shortcuts

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