commands

package
v0.70.1 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 50 Imported by: 1

Documentation

Index

Constants

View Source
const SelfUpdateAvailableExitCode = 10

SelfUpdateAvailableExitCode is the `self-update --check` exit code for "an update is available" (or the running version is undetermined). It is distinct from 0 (up to date) and from the CLI's generic error exit 1 — unchanged from the old internal self-update package this replaces. Exported so main.go's process-exit-code mapping can recognize ErrSelfUpdateAvailable.

View Source
const ValidationFailedExitCode = 2

ValidationFailedExitCode is returned when the validate command completed and found that the repository does not satisfy its InGitDB definition.

Variables

View Source
var ErrSelfUpdateAvailable = errors.New("update available")

ErrSelfUpdateAvailable identifies a `self-update --check` outcome that found a newer release, or an undetermined running version, separately from other self-update and CLI failures, so the process boundary can select SelfUpdateAvailableExitCode (cli-install#req:host-owned-exit-codes).

View Source
var ErrValidationFailed = errors.New("repository validation failed")

ErrValidationFailed identifies repository validation findings separately from command configuration, I/O, startup, and other runtime failures.

Functions

func CI added in v0.37.4

func CI(
	homeDir func() (string, error),
	getWd func() (string, error),
	readDefinition func(string, ...ingitdb.ReadOption) (*ingitdb.Definition, error),
	viewBuilder materializer.ViewBuilder,
	logf func(...any),
) *cobra.Command

CI returns the ci command. Currently it executes materialize; future versions may add CI-specific optimisations such as validating and materializing only the collections affected by a pull-request diff.

func Delete

func Delete(
	homeDir func() (string, error),
	getWd func() (string, error),
	readDefinition func(string, ...ingitdb.ReadOption) (*ingitdb.Definition, error),
	newDB func(string, *ingitdb.Definition) (dal.DB, error),
	logf func(...any),
) *cobra.Command

Delete returns the `ingitdb delete` command. Two modes inherited from sqlflags: single-record (--id) and set (--from + --where|--all). --min-affected guards set-mode invocations with all-or-nothing destructive atomicity: when the matched count is below the threshold, NO record is deleted.

This command replaces the legacy `delete record`, `delete records`, `delete collection`, and `delete view` subcommands. Per cli-sql-verbs Idea: when a new verb's name collides with an old top-level command, the legacy parent is removed in the same release.

func Demo added in v0.66.0

func Demo(
	homeDir func() (string, error),
	getWd func() (string, error),
	readDefinition func(string, ...ingitdb.ReadOption) (*ingitdb.Definition, error),
	newDB func(string, *ingitdb.Definition) (dal.DB, error),
) *cobra.Command

Demo returns the `demo` command group. Without a subcommand it prints its help, listing `install`.

func Describe added in v0.65.0

func Describe(
	homeDir func() (string, error),
	getWd func() (string, error),
	readDefinition func(string, ...ingitdb.ReadOption) (*ingitdb.Definition, error),
) *cobra.Command

Describe returns the `ingitdb describe` command. Two kinds are supported: `describe collection <name>` (alias `table`) and `describe view <name>` (with `--in=<collection>` to disambiguate). `desc` is registered as a top-level alias for `describe`.

func Diff added in v0.65.0

func Diff(
	homeDir func() (string, error),
	getWd func() (string, error),
	readDefinition func(string, ...ingitdb.ReadOption) (*ingitdb.Definition, error),
	logf func(...any),
	exitCode func(int),
) *cobra.Command

Diff returns the diff command. exitCode is the process-exit seam (os.Exit in production, captured in tests): the command exits 1 when changes are found, 0 otherwise.

func Docs added in v0.26.0

func Docs(
	homeDir func() (string, error),
	getWd func() (string, error),
	readDefinition func(string, ...ingitdb.ReadOption) (*ingitdb.Definition, error),
	logf func(...any),
) *cobra.Command

Docs returns the docs command.

func Drop added in v0.64.0

func Drop(
	homeDir func() (string, error),
	getWd func() (string, error),
	readDefinition func(string, ...ingitdb.ReadOption) (*ingitdb.Definition, error),
	newDB func(string, *ingitdb.Definition) (dal.DB, error),
	logf func(...any),
) *cobra.Command

Drop returns the `ingitdb drop` command. Two kinds are supported: `drop collection <name>` and `drop view <name>`. The flags --if-exists (idempotent on missing target) and --cascade (no-op in the current data model; reserved for future cross-object dependency graphs) are inherited by both subcommands.

func Insert added in v0.61.0

func Insert(
	homeDir func() (string, error),
	getWd func() (string, error),
	readDefinition func(string, ...ingitdb.ReadOption) (*ingitdb.Definition, error),
	newDB func(string, *ingitdb.Definition) (dal.DB, error),
	logf func(...any),
	stdin io.Reader,
	isStdinTTY func() bool,
	openEditor func(string) error,
) *cobra.Command

Insert returns the `ingitdb insert` command.

Required: --into=<collection>. Exactly one data source: --data, stdin (when not a TTY), --edit (opens $EDITOR), or --empty (key-only record). Record key comes from --key or a top-level $id field in the data; supplying both with different values is rejected.

func Install added in v0.67.0

func Install() *cobra.Command

Install returns the "install" command, built from github.com/strongo/cli-helpers/cliinstall/cobracmd against ingitdb's own catalog id (cli-install#req:host-identity-from-catalog). `ingitdb install` lists the fleet CLIs relevant to ingitdb (datatug, ovdb, synchestra, specscore) with their live status, and `ingitdb install <name>...` installs them the same way ingitdb itself was installed. cobracmd.New panics if "ingitdb" is absent from the compiled catalog — a programming error TestInstall_Registration and TestSelfUpdate_PanicsWhenCatalogEntryMissing's sibling below both catch, never a runtime state a user sees.

func List

func List(
	homeDir func() (string, error),
	getWd func() (string, error),
	readDefinition func(string, ...ingitdb.ReadOption) (*ingitdb.Definition, error),
) *cobra.Command

List returns the list command.

func Materialize

func Materialize(
	homeDir func() (string, error),
	getWd func() (string, error),
	readDefinition func(string, ...ingitdb.ReadOption) (*ingitdb.Definition, error),
	viewBuilder materializer.ViewBuilder,
	logf func(...any),
) *cobra.Command

Materialize returns the materialize command.

func NewSkillsConfig added in v0.68.0

func NewSkillsConfig(currentVersion string) (skillsync.Config, error)

NewSkillsConfig builds the skillsync.Config for embedded inGitDB skills.

func NewUninstallCommand added in v0.68.0

func NewUninstallCommand() *cobra.Command

NewUninstallCommand returns the "uninstall" command built from cliinstall/cobracmd.

func NewValidationFailedError added in v0.65.13

func NewValidationFailedError(err error) error

NewValidationFailedError preserves a human-readable finding while making it possible for the process boundary to select ValidationFailedExitCode.

func Pull

func Pull(
	homeDir func() (string, error),
	getWd func() (string, error),
	readDefinition func(string, ...ingitdb.ReadOption) (*ingitdb.Definition, error),
	viewBuilder materializer.ViewBuilder,
	logf func(...any),
	isTerminal func() bool,
	runConflictsTUI func(context.Context, []string) error,
) *cobra.Command

Pull returns the pull command. It runs `git pull` with the chosen strategy, delegates conflict resolution to the shared working-tree engine, rebuilds materialized views, and prints a summary of the record changes the pull brought in.

func Rebase added in v0.27.0

func Rebase(
	getWd func() (string, error),
	readDefinition func(string, ...ingitdb.ReadOption) (*ingitdb.Definition, error),
	logf func(...any),
) *cobra.Command

func Resolve

func Resolve(
	homeDir func() (string, error),
	getWd func() (string, error),
	readDefinition func(string, ...ingitdb.ReadOption) (*ingitdb.Definition, error),
	logf func(...any),
	isTerminal func() bool,
	runConflictsTUI func(ctx context.Context, files []string) error,
) *cobra.Command

Resolve returns the resolve command. It is the working-tree conflict engine: it auto-resolves merge conflicts in generated files (collection README.md) by regenerating them from source records and staging them, independent of which git operation produced the conflict. Source-data conflicts that need a human decision are handed to runConflictsTUI (interactive) on a terminal, or reported as text otherwise.

func ResolveDBPathArgs added in v0.52.0

func ResolveDBPathArgs(
	dirPath string,
	homeDir func() (string, error),
	getWd func() (string, error),
) (string, error)

ResolveDBPathArgs resolves a database directory path from an explicit dirPath string (e.g. from a --path flag already read by the caller), falling back to getWd when dirPath is empty. Home-directory expansion ("~") is applied via homeDir.

func Select added in v0.60.0

func Select(
	homeDir func() (string, error),
	getWd func() (string, error),
	readDefinition func(string, ...ingitdb.ReadOption) (*ingitdb.Definition, error),
	newDB func(string, *ingitdb.Definition) (dal.DB, error),
	logf func(...any),
) *cobra.Command

Select returns the `ingitdb select` command. It queries records from a single collection in either single-record mode (--id) or set mode (--from with optional --where/--order-by/--fields/--limit/--min-affected). Output format defaults to yaml in single-record mode and csv in set mode.

func SelfUpdate added in v0.65.0

func SelfUpdate(ver string) *cobra.Command

SelfUpdate returns the "self-update" command, built from github.com/strongo/cli-helpers/selfupdate/cobracmd against ingitdbSelfUpdateConfig's identity.

Note: there is deliberately no "update" alias — `ingitdb update` is the SQL UPDATE verb command.

func Setup

func Setup() *cobra.Command

Setup returns the setup command.

func Skills added in v0.68.0

func Skills(currentVersion string) *cobra.Command

Skills returns the "skills" command built from skillsync/cobracmd.

func Uninstall added in v0.68.0

func Uninstall() *cobra.Command

Uninstall returns the "uninstall" command built from cliinstall/cobracmd.

func Update added in v0.9.0

func Update(
	homeDir func() (string, error),
	getWd func() (string, error),
	readDefinition func(string, ...ingitdb.ReadOption) (*ingitdb.Definition, error),
	newDB func(string, *ingitdb.Definition) (dal.DB, error),
	logf func(...any),
) *cobra.Command

Update returns the `ingitdb update` command. Two modes inherited from sqlflags: single-record (--id) and set (--from + --where|--all). Patch operations: --set (repeatable assignment) and --unset (comma-separated field list). Shallow patch at the top level. --min-affected guards set-mode invocations with all-or-nothing semantics.

func Upgrade added in v0.67.0

func Upgrade(ver string) *cobra.Command

Upgrade returns the "upgrade" command, built from github.com/strongo/cli-helpers/cliinstall/cobracmd against ingitdb's own catalog id. HostConfig comes from the exact same ingitdbSelfUpdateConfig helper SelfUpdate uses, so `ingitdb self-update` and `ingitdb upgrade ingitdb` reach the exact same library call (cli-install#req:self-update-equals-upgrade-self). No "update" alias: `ingitdb update` is, and stays, the SQL UPDATE verb command (cli-install#req:update-alias-policy: "ingitdb MUST NOT gain one, because its `update` command edits records").

func Validate

func Validate(
	homeDir func() (string, error),
	getWd func() (string, error),
	readDefinition func(string, ...ingitdb.ReadOption) (*ingitdb.Definition, error),
	dataVal datavalidator.DataValidator,
	incVal datavalidator.IncrementalValidator,
	logf func(...any),
) *cobra.Command

Validate returns the validate command.

Types

type GitHubDBFactory added in v0.14.0

type GitHubDBFactory interface {
	NewGitHubDBWithDef(cfg dalgo2ghingitdb.Config, def *ingitdb.Definition) (dal.DB, error)
}

GitHubDBFactory creates a GitHub-backed DAL database.

type GitHubFileReaderFactory added in v0.14.0

type GitHubFileReaderFactory interface {
	NewGitHubFileReader(cfg dalgo2ghingitdb.Config) (dalgo2ghingitdb.FileReader, error)
}

GitHubFileReaderFactory creates a GitHub file reader.

type TreeWriterFactory added in v0.65.0

type TreeWriterFactory interface {
	NewTreeWriter(cfg dalgo2ghingitdb.Config) (treeWriter, error)
}

TreeWriterFactory creates a treeWriter for atomic multi-file commits.

type ViewBuilderFactory added in v0.14.0

type ViewBuilderFactory interface {
	ViewBuilderForCollection(colDef *ingitdb.CollectionDef) (materializer.ViewBuilder, error)
}

ViewBuilderFactory creates a view builder for a collection.

Directories

Path Synopsis
Package sqlflags implements the shared CLI flag grammar for the SQL-verb commands (select, insert, update, delete, drop).
Package sqlflags implements the shared CLI flag grammar for the SQL-verb commands (select, insert, update, delete, drop).

Jump to

Keyboard shortcuts

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