Documentation
¶
Index ¶
- Constants
- Variables
- func DetermineConfigPath(dir string) string
- func IsVfoxRelatedPath(path string) bool
- type Attr
- type FileRecord
- type PathMeta
- type SharedPaths
- type ToolConfig
- type ToolVersions
- type Tools
- func (t *Tools) Get(name string) (*ToolConfig, bool)
- func (t *Tools) GetVersion(name string) (string, bool)
- func (t *Tools) Len() int
- func (t *Tools) List() ToolVersions
- func (t *Tools) MarshalTOML() ([]byte, error)
- func (t *Tools) Remove(name string)
- func (t *Tools) Set(name, version string)
- func (t *Tools) SetWithAttr(name, version string, attr Attr)
- func (t *Tools) SortedKeys() []string
- func (t *Tools) UnmarshalTOML(data interface{}) error
- type UserPaths
- type VfoxToml
- func (v *VfoxToml) GetAllTools() ToolVersions
- func (v *VfoxToml) GetToolConfig(name string) (*ToolConfig, bool)
- func (v *VfoxToml) GetToolVersion(name string) (string, bool)
- func (v *VfoxToml) IsEmpty() bool
- func (v *VfoxToml) IsNew() bool
- func (v *VfoxToml) MarshalTOML() ([]byte, error)
- func (v *VfoxToml) RemoveTool(name string)
- func (v *VfoxToml) Save() error
- func (v *VfoxToml) SaveTo(dir string) error
- func (v *VfoxToml) SaveToPath(path string) error
- func (v *VfoxToml) SetTool(name, version string)
- func (v *VfoxToml) SetToolWithAttr(name, version string, attr Attr)
- type WorkingPaths
Constants ¶
const ( HookCurTmpPath = "__VFOX_CURTMPPATH" ReadWriteAuth = 0755 // can write and read )
Variables ¶
var ConfigFileNames = []string{
".vfox.toml",
"vfox.toml",
}
ConfigFileNames defines the config file names and their priority
Functions ¶
func DetermineConfigPath ¶
DetermineConfigPath determines the default path for the config file Used for path inference when saving new configs
func IsVfoxRelatedPath ¶
IsVfoxRelatedPath checks if the given path is related to vfox
Types ¶
type FileRecord ¶
type FileRecord struct {
Record map[string]string
Path string
// contains filtered or unexported fields
}
FileRecord is a file that contains a map of string to string
func NewFileRecord ¶
func NewFileRecord(path string) (*FileRecord, error)
NewFileRecord creates a new FileRecord from a file if the file does not exist, an empty FileRecord is returned
func (*FileRecord) Save ¶
func (m *FileRecord) Save() error
type PathMeta ¶
type PathMeta struct {
User UserPaths
Working WorkingPaths
Executable string // Executable path
}
func NewPathMeta ¶
NewPathMeta creates a new PathMeta instance based on the provided parameters and environment variables. If not provide sharedRoot, it will use userHome as sharedRoot.
func (*PathMeta) ApplyStoragePath ¶ added in v1.0.2
ApplyStoragePath applies the storage path from config to update the Installs path If storagePath is empty, the current Installs path is unchanged
type SharedPaths ¶
type SharedPaths struct {
}
type ToolConfig ¶
ToolConfig represents a tool configuration with version and optional attributes Supports two formats: 1. Simple: nodejs = "21.5.1" 2. Complex: java = { version = "21", vendor = "openjdk" }
func (*ToolConfig) MarshalInline ¶
func (t *ToolConfig) MarshalInline() string
MarshalInline serializes the tool configuration to an inline TOML value Returns just the value part (without the key), e.g.:
- "21.5.1" (for simple format)
- {version = "21", vendor = "openjdk"} (for complex format)
func (*ToolConfig) UnmarshalTOML ¶
func (t *ToolConfig) UnmarshalTOML(data interface{}) error
UnmarshalTOML custom unmarshaling to support both simple and complex formats
type ToolVersions ¶
ToolVersions is a type alias for map of tool name to version
type Tools ¶
type Tools map[string]*ToolConfig
Tools is a map of tool name to tool configuration
func (*Tools) Get ¶
func (t *Tools) Get(name string) (*ToolConfig, bool)
Get retrieves a tool configuration
func (*Tools) GetVersion ¶
GetVersion retrieves only the version of a tool
func (*Tools) List ¶
func (t *Tools) List() ToolVersions
List returns all tools as a map of name -> version
func (*Tools) MarshalTOML ¶
MarshalTOML implements the toml.Marshaler interface
func (*Tools) SetWithAttr ¶
SetWithAttr adds or updates a tool configuration with attributes
func (*Tools) SortedKeys ¶
SortedKeys returns a sorted list of tool names
func (*Tools) UnmarshalTOML ¶
UnmarshalTOML implements the toml.Unmarshaler interface
type VfoxToml ¶
type VfoxToml struct {
Tools Tools `toml:"tools"`
Path string // Config file path (empty for new configs)
}
VfoxToml represents the vfox.toml configuration file Example:
[tools]
nodejs = "21.5.1"
java = { version = "21", vendor = "openjdk" }
func LoadConfig ¶
LoadConfig loads the config file from the specified directory Priority: .vfox.toml > vfox.toml > .tool-versions If .tool-versions is read, it will be automatically saved as .vfox.toml (without deleting the original file) pathmeta is not aware of scope, the caller should set it
func LoadVfoxToml ¶
LoadVfoxToml loads vfox.toml from the specified path Returns an empty VfoxToml if the file doesn't exist
func (*VfoxToml) GetAllTools ¶
func (v *VfoxToml) GetAllTools() ToolVersions
GetAllTools returns all tools as a ToolVersions map (name -> version)
func (*VfoxToml) GetToolConfig ¶
func (v *VfoxToml) GetToolConfig(name string) (*ToolConfig, bool)
GetToolConfig retrieves the complete tool configuration (including attributes)
func (*VfoxToml) GetToolVersion ¶
GetToolVersion retrieves only the version of a tool
func (*VfoxToml) MarshalTOML ¶
MarshalTOML serializes the configuration to TOML format
func (*VfoxToml) RemoveTool ¶
RemoveTool removes a tool from the configuration
func (*VfoxToml) Save ¶
Save saves the config to the recorded Path Returns error if Path is empty or config is empty
func (*VfoxToml) SaveTo ¶
SaveTo saves the config to the specified directory (auto-selects filename) Prefers .vfox.toml, uses vfox.toml if it already exists Does not create a file if the config is empty
func (*VfoxToml) SaveToPath ¶
SaveToPath saves the config to the specified full path If the config is empty:
- If file doesn't exist: do nothing (don't create file)
- If file exists: update it with empty [tools] section
func (*VfoxToml) SetToolWithAttr ¶
SetToolWithAttr sets or updates a tool configuration with attributes