store

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package store manages scratchpad file persistence including encryption and path resolution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureGitignore

func EnsureGitignore(contextDir, filename string) error

EnsureGitignore adds an entry to .gitignore if not already present.

Parameters:

  • contextDir: The .context directory path
  • filename: The file to add (joined with contextDir)

Returns:

  • error: Non-nil on read/write failure

func EnsureKey

func EnsureKey(cmd *cobra.Command) error

EnsureKey generates a scratchpad key when none exists.

If an encrypted scratchpad already exists without a key, returns an error (a new key would not decrypt the existing data). On first use this lets `ctx pad add` work without requiring `ctx init`.

Parameters:

  • cmd: Cobra command for diagnostic output

Returns:

  • error: Non-nil on missing key with existing data, or generation failure

func KeyPath

func KeyPath() string

KeyPath returns the full path to the encryption key file.

Triggers legacy key migration on each call, then resolves the effective path via rc.KeyPath().

Returns:

  • string: Resolved key file path

func ReadEntries

func ReadEntries() ([]string, error)

ReadEntries reads the scratchpad and returns its entries.

If the scratchpad file does not exist, it returns an empty slice (no error). If the encrypted file exists but the key is missing, it returns an error.

Returns:

  • []string: The scratchpad entries (may be empty)
  • error: Non-nil on key or decryption errors

func ScratchpadPath

func ScratchpadPath() string

ScratchpadPath returns the full path to the scratchpad file.

Returns:

  • string: Encrypted or plaintext path based on rc.ScratchpadEncrypt()

func WriteEntries

func WriteEntries(cmd *cobra.Command, entries []string) error

WriteEntries writes entries to the scratchpad file.

In encrypted mode, the entries are encrypted with AES-256-GCM before writing. In plaintext mode, they are written as a newline-delimited file.

Parameters:

  • cmd: Cobra command for diagnostic output
  • entries: The scratchpad entries to write

Returns:

  • error: Non-nil on key, encryption, or file write errors

Types

This section is empty.

Jump to

Keyboard shortcuts

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