commands

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package commands implements all CLI commands for the kiln secure environment variable management tool. It provides subcommands for initializing projects, editing encrypted files, running commands with decrypted environment variables, and managing encryption keys.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplyCmd added in v1.0.1

type ApplyCmd struct {
	File           string `short:"f" help:"Environment file from configuration" default:"default"`
	Output         string `short:"o" help:"Output file path (default: stdout)"`
	Strict         bool   `help:"Fail if template variables are not found"`
	LeftDelimiter  string `help:"Left delimiter to use for template variables (default: ${ or $)"`
	RightDelimiter string `help:"Right delimiter to use for template variables (default: } or empty)"`
	Template       string `arg:"" help:"Template file path" required:""`
}

ApplyCmd represents the apply command to safely apply variables to a template file.

func (*ApplyCmd) Run added in v1.0.1

func (c *ApplyCmd) Run(rt *Runtime) error

Run executes the apply command, substituting variables in the template file.

type EditCmd

type EditCmd struct {
	File   string `short:"f" help:"Environment file to edit" default:"default"`
	Editor string `help:"Editor to use for editing the file, defaults to the EDITOR environment variable" placeholder:"EDITOR"`
}

EditCmd represents the edit command for modifying encrypted environment variables.

func (*EditCmd) Run

func (c *EditCmd) Run(rt *Runtime) error

Run executes the edit command, opening an editor to modify environment variables.

type ExitError

type ExitError struct {
	Code int
}

ExitError represents a command exit with a specific code.

func (*ExitError) Error

func (e *ExitError) Error() string

Error returns a exit-code formatted error.

type ExportCmd

type ExportCmd struct {
	File   string `short:"f" help:"Environment file from the configuration to export" default:"default"`
	Format string `help:"Output format" enum:"shell,json,yaml" default:"shell" placeholder:"[shell|json|yaml]"`
}

ExportCmd represents the export command for outputting environment variables.

func (*ExportCmd) Run

func (c *ExportCmd) Run(rt *Runtime) error

Run executes the export command, outputting variables in the specified format.

type GetCmd

type GetCmd struct {
	Name   string `arg:"" help:"Environment variable name"`
	File   string `short:"f" help:"Environment file to read from" default:"default"`
	Format string `help:"Output format" enum:"value,json" default:"value"`
}

GetCmd represents the get command for retrieving a single environment variable.

func (*GetCmd) Run

func (c *GetCmd) Run(rt *Runtime) error

Run executes the get command, retrieving and displaying a specific variable.

type InfoCmd

type InfoCmd struct {
	File   string `short:"f" help:"Show info for specific file"`
	Verify bool   `help:"Verify file decryption capability" default:"false"`
}

InfoCmd represents the info command for displaying project and file information.

func (*InfoCmd) Run

func (c *InfoCmd) Run(rt *Runtime) error

Run executes the info command, showing file status and verification details.

type InitCmd

type InitCmd struct {
	Key    *InitKeyCmd    `cmd:"" help:"Generate encryption key"`
	Config *InitConfigCmd `cmd:"" help:"Generate configuration file"`
}

InitCmd represents the init command for initializing kiln projects.

type InitConfigCmd

type InitConfigCmd struct {
	Path       string            `help:"Path for config file" default:"kiln.toml"`
	Recipients map[string]string `help:"Named recipients in format 'name=key'" type:"agepubkey"`
	Force      bool              `help:"Overwrite existing config"`
}

InitConfigCmd represents the config generation subcommand of init.

func (*InitConfigCmd) Run

func (c *InitConfigCmd) Run(rt *Runtime) error

Run executes the init config command, creating a new configuration file.

type InitKeyCmd

type InitKeyCmd struct {
	Path    string `help:"Path for private key" default:"~/.kiln/kiln.key" type:"path"`
	Encrypt bool   `help:"Save key with passphrase protection"`
	Force   bool   `help:"Overwrite existing key (dangerous!)"`
}

InitKeyCmd represents the key generation subcommand of init.

func (*InitKeyCmd) Run

func (c *InitKeyCmd) Run(rt *Runtime) error

Run executes the init key command, generating a new encryption key pair.

type RekeyCmd

type RekeyCmd struct {
	File         string   `short:"f" help:"Environment file to rekey" required:"true"`
	AddRecipient []string `help:"Add new named recipients in format 'name=key'" placeholder:"name=age-pub-key"`
	Force        bool     `help:"Force rekey without confirmation"`
}

RekeyCmd represents the rekey command for rotating encryption keys.

func (*RekeyCmd) Run

func (c *RekeyCmd) Run(rt *Runtime) error

Run executes the rekey command, re-encrypting files with updated recipients.

type RunCmd

type RunCmd struct {
	File    string        `short:"f" help:"Environment file to use" default:"default"`
	DryRun  bool          `help:"Show environment variables without running command"`
	Timeout time.Duration `help:"Timeout for command execution" placeholder:"[10s]"`
	WorkDir string        `help:"Working directory for command execution" placeholder:"[path]"`
	Shell   bool          `help:"Run command through shell"`
	Command []string      `arg:"" help:"Command and arguments to run"`
}

RunCmd represents the run command for executing programs with encrypted environment variables.

func (*RunCmd) Run

func (c *RunCmd) Run(rt *Runtime) error

Run executes the run command, loading environment variables and executing the specified command.

type Runtime

type Runtime struct {
	Logger zerolog.Logger
	// contains filtered or unexported fields
}

Runtime contains shared configuration and provides lazy loading for commands

func NewRuntime

func NewRuntime(configPath, keyPath string, verbose bool) (*Runtime, error)

NewRuntime creates a new context with configured logger

func (*Runtime) Cleanup

func (rt *Runtime) Cleanup()

Cleanup wipes sensitive data from memory

func (*Runtime) Config

func (rt *Runtime) Config() (*config.Config, error)

Config returns the configuration, loading it on first access

func (*Runtime) ConfigPath

func (rt *Runtime) ConfigPath() string

ConfigPath returns the configuration file path

func (*Runtime) Context

func (rt *Runtime) Context() context.Context

Context returns a context for command operations

func (*Runtime) Identity

func (rt *Runtime) Identity() (*core.Identity, error)

Identity returns the loaded identity

type SetCmd

type SetCmd struct {
	Name     string `arg:"" help:"Environment variable name" optional:""`
	Value    string `arg:"" help:"Environment variable value (if not provided, will prompt for input)" optional:""`
	File     string `short:"f" help:"Environment file to modify" default:"default"`
	FromFile string `help:"JSON file containing environment variables to set" type:"path"`
}

SetCmd represents the set command for adding or updating environment variables.

func (*SetCmd) Run

func (c *SetCmd) Run(rt *Runtime) error

Run executes the set command, prompting for and storing environment variable(s).

Jump to

Keyboard shortcuts

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