toolversions

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package toolversions handles reading and writing tools and versions from asdf's .tool-versions files. It also handles parsing version strings from .tool-versions files and command line arguments.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindToolVersions

func FindToolVersions(filepath, toolName string) (versions []string, found bool, err error)

FindToolVersions looks up a tool version in a tool versions file and if found returns a slice of versions for it.

func Format

func Format(version Version) string

Format takes a Version struct and formats it as a string

func FormatForFS

func FormatForFS(version Version) string

FormatForFS takes a versionType and version strings and generate a version string suitable for the file system

func Intersect

func Intersect(versions1 []string, versions2 []string) (versions []string)

Intersect takes two slices of versions and returns a new slice containing only the versions found in both.

func VersionStringFromFSFormat added in v0.17.0

func VersionStringFromFSFormat(version string) string

VersionStringFromFSFormat takes a version string from directory name and formats it as version string that can be parsed by the Parse function.

func WriteToolVersionsToFile

func WriteToolVersionsToFile(filepath string, toolVersions []ToolVersions) error

WriteToolVersionsToFile takes a path to a file and writes the new tool and version data to the file. It creates the file if it does not exist and updates it if it does.

Types

type ToolVersions

type ToolVersions struct {
	Name     string
	Versions []string
}

ToolVersions represents a tool along with versions specified for it

func GetAllToolsAndVersions

func GetAllToolsAndVersions(filepath string) (toolVersions []ToolVersions, err error)

GetAllToolsAndVersions returns a list of all tools and associated versions contained in a .tool-versions file

func Unique

func Unique(versions []ToolVersions) (uniques []ToolVersions)

Unique takes a slice of ToolVersions and returns a slice of unique tools and versions.

type Version

type Version struct {
	Type  string // Must be one of: version, ref, path, system, latest
	Value string // Any string
}

Version struct represents a single version in asdf.

func Parse

func Parse(version string) Version

Parse parses a version string into versionType and version components

func ParseFromCliArg

func ParseFromCliArg(version string) Version

ParseFromCliArg parses a string that is passed in as an argument to one of the asdf subcommands. Some subcommands allow the special version `latest` to be used, with an optional filter string.

func ParseSlice

func ParseSlice(versions []string) (parsedVersions []Version)

ParseSlice takes a slice of strings and returns a slice of parsed versions.

Jump to

Keyboard shortcuts

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