Documentation
¶
Index ¶
- Constants
- func CreateDirSymlink(target, link string) error
- func GetPid() int
- func GetVfoxHome() string
- func IsDirSymlink(path string) bool
- func IsHookEnv() bool
- func IsMultiplexerEnvironment() bool
- func ReadDirSymlink(link string) (string, error)
- func RemoveDirSymlink(link string) error
- type ConfigState
- type Envs
- type PathFrom
- type Paths
- type RuntimeEnvContext
- func (m *RuntimeEnvContext) CleanSystemPaths() *Paths
- func (m *RuntimeEnvContext) GetLinkDirPathByScope(scope UseScope) string
- func (m *RuntimeEnvContext) HttpClient() *http.Client
- func (m *RuntimeEnvContext) LoadVfoxTomlByScope(scope UseScope) (*pathmeta.VfoxToml, error)
- func (m *RuntimeEnvContext) LoadVfoxTomlChainByScopes(scopes ...UseScope) (VfoxTomlChain, error)
- type UseScope
- type Vars
- type VfoxTomlChain
- func (c *VfoxTomlChain) Add(config *pathmeta.VfoxToml, useScope UseScope)
- func (c *VfoxTomlChain) AddTool(name, version string)
- func (c *VfoxTomlChain) GetAllTools() pathmeta.ToolVersions
- func (c *VfoxTomlChain) GetByIndex(index int) *pathmeta.VfoxToml
- func (c *VfoxTomlChain) GetTomlByScope(scope UseScope) (*pathmeta.VfoxToml, bool)
- func (c *VfoxTomlChain) GetToolConfig(name string) (*pathmeta.ToolConfig, UseScope, bool)
- func (c *VfoxTomlChain) GetToolVersion(name string) (string, UseScope, bool)
- func (c *VfoxTomlChain) IsEmpty() bool
- func (c *VfoxTomlChain) Length() int
- func (c *VfoxTomlChain) Merge() *pathmeta.VfoxToml
- func (c *VfoxTomlChain) RemoveTool(name string)
- func (c *VfoxTomlChain) Save() error
Constants ¶
const ( HomeFromEnv = "VFOX_HOME" HookFlag = "__VFOX_SHELL" PidFlag = "__VFOX_PID" )
const Newline = "\n"
const PathVarName = "PATH"
Variables ¶
This section is empty.
Functions ¶
func CreateDirSymlink ¶ added in v1.0.0
CreateDirSymlink creates a directory symbolic link on Unix systems
func GetVfoxHome ¶ added in v0.6.6
func GetVfoxHome() string
func IsDirSymlink ¶ added in v1.0.0
IsDirSymlink checks if the given path is a directory symbolic link
func IsMultiplexerEnvironment ¶ added in v0.10.0
func IsMultiplexerEnvironment() bool
IsMultiplexerEnvironment detects if the current shell session is running inside a multiplexer or other environment where new panes/windows should have isolated environments. This includes tmux, screen, and potentially other terminal multiplexers.
Supported multiplexers:
- tmux: Detects via TMUX environment variable
Returns true if running in a multiplexer environment.
func ReadDirSymlink ¶ added in v1.0.0
ReadDirSymlink reads the target of a directory symbolic link
func RemoveDirSymlink ¶ added in v1.0.0
RemoveDirSymlink removes a directory symbolic link on Unix systems
Types ¶
type ConfigState ¶ added in v1.0.0
type ConfigState struct {
// Last check time (Unix timestamp in seconds)
LastCheck int64 `json:"last_check"`
// Current project config path (to detect directory/project changes)
CurrentProjectPath string `json:"current_project_path,omitempty"`
// Config file modification times (Unix timestamps in seconds)
GlobalMtime int64 `json:"global_mtime,omitempty"`
SessionMtime int64 `json:"session_mtime,omitempty"`
ProjectMtime int64 `json:"project_mtime,omitempty"`
// Cached PATH value (to detect user-made PATH changes)
CachedPath string `json:"cached_path,omitempty"`
// Cached env output (shell script)
CachedOutput string `json:"cached_output,omitempty"`
// contains filtered or unexported fields
}
ConfigState tracks the state of configuration files for diff checking
func NewConfigState ¶ added in v1.0.0
func NewConfigState(stateFilePath string) *ConfigState
NewConfigState creates a new ConfigState with the given state file path
func (*ConfigState) GetCachedOutput ¶ added in v1.0.0
func (s *ConfigState) GetCachedOutput() string
GetCachedOutput returns the cached env output
func (*ConfigState) HasChanged ¶ added in v1.0.0
func (s *ConfigState) HasChanged(configPaths map[UseScope]string) (bool, error)
HasChanged checks if any config file has changed based on modification time Returns true if any config file has been modified since last check, or if project directory changed, or if PATH changed
func (*ConfigState) Load ¶ added in v1.0.0
func (s *ConfigState) Load() error
Load loads the state from disk
func (*ConfigState) Save ¶ added in v1.0.0
func (s *ConfigState) Save() error
Save saves the state to disk
type Envs ¶
Envs is a struct that contains environment variables and PATH.
func (*Envs) MergeByScopePriority ¶ added in v1.0.0
MergeByScopePriority merges envs from different scopes with proper priority scopePriority: list of scopes in order from HIGHEST to LOWEST priority For example: [Project, Session, Global] means Project has highest priority
NOTE: PATH and Vars are merged differently due to their different semantics: - Paths.Merge appends (first added has higher priority) - Vars.Merge overwrites (last added wins)
So this method handles them separately: - Paths: merged in given order (HIGHEST priority first) - Vars: merged in reverse order (LOWEST priority first, HIGHEST overrides)
type Paths ¶ added in v0.2.5
Paths is a slice of PATH.
func NewPaths ¶ added in v0.3.0
NewPaths returns a new Paths. from is the source of the paths. If from is OsPaths, it returns the paths from the environment variable PATH.
func (*Paths) ToBinPaths ¶ added in v0.5.0
ToBinPaths returns a BinPaths from Paths which contains only executable files.
type RuntimeEnvContext ¶ added in v1.0.0
type RuntimeEnvContext struct {
UserConfig *config.Config // UserConfig holds the user configuration.
CurrentWorkingDir string // CurrentWorkingDir is the current working directory.
PathMeta *pathmeta.PathMeta // PathMeta holds the path info of the environment.
RuntimeVersion string // RuntimeVersion is the version of vfox
}
RuntimeEnvContext represents the runtime environment context.
func (*RuntimeEnvContext) CleanSystemPaths ¶ added in v1.0.0
func (m *RuntimeEnvContext) CleanSystemPaths() *Paths
CleanSystemPaths returns system PATH with all vfox-managed paths removed (prefix match). This ensures the system PATH is clean before adding vfox paths back in priority order.
func (*RuntimeEnvContext) GetLinkDirPathByScope ¶ added in v1.0.0
func (m *RuntimeEnvContext) GetLinkDirPathByScope(scope UseScope) string
GetLinkDirPathByScope returns the symlink directory path for the given scope.
func (*RuntimeEnvContext) HttpClient ¶ added in v1.0.0
func (m *RuntimeEnvContext) HttpClient() *http.Client
HttpClient creates an HTTP client based on the proxy settings in the user configuration.
func (*RuntimeEnvContext) LoadVfoxTomlByScope ¶ added in v1.0.0
func (m *RuntimeEnvContext) LoadVfoxTomlByScope(scope UseScope) (*pathmeta.VfoxToml, error)
LoadVfoxTomlByScope loads the config for the specified scope pathmeta is not aware of scope, but we don't need to track it in VfoxToml
func (*RuntimeEnvContext) LoadVfoxTomlChainByScopes ¶ added in v1.0.0
func (m *RuntimeEnvContext) LoadVfoxTomlChainByScopes(scopes ...UseScope) (VfoxTomlChain, error)
LoadVfoxTomlChainByScopes loads configs for multiple scopes and returns a chain Scopes are added in order (first added = lowest priority) Example: LoadVfoxTomlChainByScopes(Global, Session, Project) → Project has highest priority
type VfoxTomlChain ¶ added in v1.0.0
type VfoxTomlChain []*chainItem
VfoxTomlChain is a chain of VfoxToml configs, supporting multi-config merging
func NewVfoxTomlChain ¶ added in v1.0.0
func NewVfoxTomlChain() VfoxTomlChain
NewVfoxTomlChain creates a new config chain
func (*VfoxTomlChain) Add ¶ added in v1.0.0
func (c *VfoxTomlChain) Add(config *pathmeta.VfoxToml, useScope UseScope)
Add appends a config to the end of the chain
func (*VfoxTomlChain) AddTool ¶ added in v1.0.0
func (c *VfoxTomlChain) AddTool(name, version string)
AddTool adds a tool to all configs in the chain
func (*VfoxTomlChain) GetAllTools ¶ added in v1.0.0
func (c *VfoxTomlChain) GetAllTools() pathmeta.ToolVersions
GetAllTools returns all tools after merging
func (*VfoxTomlChain) GetByIndex ¶ added in v1.0.0
func (c *VfoxTomlChain) GetByIndex(index int) *pathmeta.VfoxToml
GetByIndex returns the config at the specified index
func (*VfoxTomlChain) GetTomlByScope ¶ added in v1.0.0
func (c *VfoxTomlChain) GetTomlByScope(scope UseScope) (*pathmeta.VfoxToml, bool)
GetTomlByScope returns the config and scope for the given scope
func (*VfoxTomlChain) GetToolConfig ¶ added in v1.0.0
func (c *VfoxTomlChain) GetToolConfig(name string) (*pathmeta.ToolConfig, UseScope, bool)
GetToolConfig retrieves a tool config (searches by priority) Searches from tail to head (high priority to low priority)
func (*VfoxTomlChain) GetToolVersion ¶ added in v1.0.0
func (c *VfoxTomlChain) GetToolVersion(name string) (string, UseScope, bool)
GetToolVersion retrieves only the version of a tool (searches by priority)
func (*VfoxTomlChain) IsEmpty ¶ added in v1.0.0
func (c *VfoxTomlChain) IsEmpty() bool
IsEmpty checks if the chain is empty
func (*VfoxTomlChain) Length ¶ added in v1.0.0
func (c *VfoxTomlChain) Length() int
Length returns the length of the config chain
func (*VfoxTomlChain) Merge ¶ added in v1.0.0
func (c *VfoxTomlChain) Merge() *pathmeta.VfoxToml
Merge merges configs by priority Later configs in the chain override earlier ones (if the same tool exists) Example: [Global, Session, Project] → Project has highest priority
func (*VfoxTomlChain) RemoveTool ¶ added in v1.0.0
func (c *VfoxTomlChain) RemoveTool(name string)
RemoveTool removes a tool from all configs in the chain
func (*VfoxTomlChain) Save ¶ added in v1.0.0
func (c *VfoxTomlChain) Save() error
Save saves all configs in the chain Calls Save() on each VfoxToml (which won't create files if empty)