cmdutil

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package cmdutil provides shared helpers for CLI command implementations.

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyWritten = errors.New("error already written to output")

ErrAlreadyWritten signals that a JSON error envelope was already written.

Functions

func LoadRegistry

func LoadRegistry(vaultPath string) (*schema.Registry, error)

LoadRegistry loads only the type registry from a vault's .vaultmind/config.yaml without opening the index database. Use this when you need schema information (e.g., for live validation) but not the index itself.

func WriteJSON

func WriteJSON(w io.Writer, command string, result interface{}, vaultPath, indexHash string) error

WriteJSON writes a JSON envelope to the writer.

func WriteJSONError

func WriteJSONError(w io.Writer, command, code, message string) error

WriteJSONError writes a JSON error envelope to the writer.

Types

type VaultDB

type VaultDB struct {
	DB     *index.DB
	Config *vault.Config
	Reg    *schema.Registry
	// contains filtered or unexported fields
}

VaultDB bundles the commonly needed vault resources.

func OpenVaultDB

func OpenVaultDB(vaultPath string) (*VaultDB, error)

OpenVaultDB loads config, opens the index DB, and creates the type registry.

func OpenVaultDBOrWriteErr

func OpenVaultDBOrWriteErr(cmd *cobra.Command, vaultPath, commandName string) (*VaultDB, error)

OpenVaultDBOrWriteErr opens the vault DB. On failure with --json set, writes a JSON error envelope and returns ErrAlreadyWritten.

func (*VaultDB) Close

func (v *VaultDB) Close()

Close releases the database connection.

func (*VaultDB) GetIndexHash

func (v *VaultDB) GetIndexHash() string

GetIndexHash returns the cached SHA-256 hash of the SQLite database file.

func (*VaultDB) IndexHash

func (v *VaultDB) IndexHash() string

IndexHash computes the SHA-256 hash of the SQLite database file. Uses streaming hash to avoid loading the entire file into memory.

Jump to

Keyboard shortcuts

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