env

package
v0.2.19 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendHistory

func AppendHistory(envName, command string) error

func BasePath

func BasePath() (string, error)

func Clear

func Clear(name string, keepHistory bool) error

func Create

func Create(name string) error

func Delete

func Delete(name string) error

func EnsureBaseStructure

func EnsureBaseStructure() error

func EnsureDefaultEnvironment

func EnsureDefaultEnvironment() error

func EnvsPath

func EnvsPath() (string, error)

func Exists

func Exists(name string) bool

func Export

func Export(name, outputPath string) error

func GlobalConfigPath

func GlobalConfigPath() (string, error)

func Import

func Import(inputPath, targetName string, force bool) (string, error)

func Open

func Open(name string) (string, error)

func ReadHistory

func ReadHistory(envName string) ([]string, error)

func Rename

func Rename(oldName, newName string) error

func ResolveEnvPath

func ResolveEnvPath(name string) (string, error)

func RestoreVariables

func RestoreVariables(envName string) (map[string]any, error)

func SaveGlobalConfig

func SaveGlobalConfig(cfg GlobalConfig) error

func SaveState

func SaveState(envName string, vars map[string]any) error

func SetBasePath added in v0.2.18

func SetBasePath(path string)

SetBasePath overrides the default Manager's root. Pass "" to restore the default <UserHomeDir>/.insyra. This only affects the package-level wrappers and any caller that explicitly uses Default(); per-session Managers created via NewManager are unaffected.

Types

type EnvironmentInfo

type EnvironmentInfo struct {
	Name          string
	Path          string
	LastAccess    time.Time
	VariableCount int
}

func Info

func Info(name string) (EnvironmentInfo, error)

func List

func List() ([]EnvironmentInfo, error)

type ExportPayload

type ExportPayload struct {
	SchemaVersion int             `json:"schemaVersion"`
	ExportedAt    string          `json:"exportedAt"`
	Environment   string          `json:"environment"`
	State         *State          `json:"state"`
	History       []string        `json:"history"`
	Config        json.RawMessage `json:"config"`
}

type GlobalConfig

type GlobalConfig struct {
	DefaultEnv string `json:"defaultEnv"`
	LogLevel   string `json:"logLevel"`
	NoColor    bool   `json:"noColor"`
}

func LoadGlobalConfig

func LoadGlobalConfig() (GlobalConfig, error)

func UpdateGlobalConfig

func UpdateGlobalConfig(key, value string) (GlobalConfig, error)

type Manager added in v0.2.18

type Manager struct {
	// contains filtered or unexported fields
}

Manager owns a single environment-storage root and exposes all env-related operations (CRUD, state, history, config) as methods.

Embedders that want per-workspace isolation should construct one Manager per workspace via NewManager. The CLI binary and any code calling the package-level wrapper functions share a single process-wide Default() Manager rooted at <UserHomeDir>/.insyra/envs (overridable via SetBasePath and SetEnvsDirName).

func Default added in v0.2.18

func Default() *Manager

Default returns the shared process-wide Manager used by the package-level wrapper functions (env.BasePath, env.Create, …) and by SetBasePath.

func NewManager added in v0.2.18

func NewManager(basePath, envsDirName string) *Manager

NewManager constructs a Manager rooted at basePath. envsDirName overrides the per-environment subfolder name; pass "" for the default "envs".

Examples:

env.NewManager("", "")                       // ~/.insyra/envs/<name>/
env.NewManager("/ws/.idensyra", "")          // /ws/.idensyra/envs/<name>/
env.NewManager("/ws/.idensyra", "insights")  // /ws/.idensyra/insights/<name>/

Both fields are fixed at construction; create a new Manager to point somewhere else.

func (*Manager) AppendHistory added in v0.2.18

func (m *Manager) AppendHistory(envName, command string) error

func (*Manager) BasePath added in v0.2.18

func (m *Manager) BasePath() (string, error)

func (*Manager) Clear added in v0.2.18

func (m *Manager) Clear(name string, keepHistory bool) error

func (*Manager) Create added in v0.2.18

func (m *Manager) Create(name string) error

func (*Manager) Delete added in v0.2.18

func (m *Manager) Delete(name string) error

func (*Manager) EnsureBaseStructure added in v0.2.18

func (m *Manager) EnsureBaseStructure() error

func (*Manager) EnsureDefaultEnvironment added in v0.2.18

func (m *Manager) EnsureDefaultEnvironment() error

func (*Manager) EnvsDirName added in v0.2.18

func (m *Manager) EnvsDirName() string

func (*Manager) EnvsPath added in v0.2.18

func (m *Manager) EnvsPath() (string, error)

func (*Manager) Exists added in v0.2.18

func (m *Manager) Exists(name string) bool

func (*Manager) Export added in v0.2.18

func (m *Manager) Export(name, outputPath string) error

func (*Manager) GlobalConfigPath added in v0.2.18

func (m *Manager) GlobalConfigPath() (string, error)

func (*Manager) Import added in v0.2.18

func (m *Manager) Import(inputPath, targetName string, force bool) (string, error)

func (*Manager) Info added in v0.2.18

func (m *Manager) Info(name string) (EnvironmentInfo, error)

func (*Manager) List added in v0.2.18

func (m *Manager) List() ([]EnvironmentInfo, error)

func (*Manager) LoadGlobalConfig added in v0.2.18

func (m *Manager) LoadGlobalConfig() (GlobalConfig, error)

func (*Manager) LoadState added in v0.2.18

func (m *Manager) LoadState(envName string) (*State, error)

func (*Manager) Open added in v0.2.18

func (m *Manager) Open(name string) (string, error)

func (*Manager) ReadHistory added in v0.2.18

func (m *Manager) ReadHistory(envName string) ([]string, error)

func (*Manager) Rename added in v0.2.18

func (m *Manager) Rename(oldName, newName string) error

func (*Manager) ResolveEnvPath added in v0.2.18

func (m *Manager) ResolveEnvPath(name string) (string, error)

func (*Manager) RestoreVariables added in v0.2.18

func (m *Manager) RestoreVariables(envName string) (map[string]any, error)

func (*Manager) SaveGlobalConfig added in v0.2.18

func (m *Manager) SaveGlobalConfig(cfg GlobalConfig) error

func (*Manager) SaveState added in v0.2.18

func (m *Manager) SaveState(envName string, vars map[string]any) error

func (*Manager) SetBasePath added in v0.2.18

func (m *Manager) SetBasePath(path string)

SetBasePath updates this Manager's root. Pass "" to fall back to the default <UserHomeDir>/.insyra. Safe to call before opening or creating any environment; not safe to change while an environment is in use.

func (*Manager) SetEnvsDirName added in v0.2.18

func (m *Manager) SetEnvsDirName(name string)

SetEnvsDirName updates this Manager's per-environment subfolder name. Pass "" to fall back to the default "envs". Same usage caveats as SetBasePath — not safe to change while an environment is in use.

func (*Manager) UpdateGlobalConfig added in v0.2.18

func (m *Manager) UpdateGlobalConfig(key, value string) (GlobalConfig, error)

type SerializedVariable

type SerializedVariable struct {
	Type string `json:"type"`
	Name string `json:"name,omitempty"`
	Data any    `json:"data"`
}

type State

type State struct {
	Variables  map[string]SerializedVariable `json:"variables"`
	LastAccess string                        `json:"lastAccess"`
}

func LoadState

func LoadState(envName string) (*State, error)

Jump to

Keyboard shortcuts

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