Documentation
¶
Index ¶
- Variables
- func DefaultDownload(url string) ([]byte, error)
- func ResolveTools(tools []Tool, flag string) []int
- func RunWithSpinner(label, version string, fn func() error) error
- type Deps
- type InstallResult
- type Installer
- func (ins *Installer) InstallAll(tools []Tool, selectedIdx []int, deps *Deps) InstallResult
- func (ins *Installer) InstallBinary(t Tool, d *Deps) error
- func (i *Installer) InstallGoInstall(t Tool, d *Deps) error
- func (ins *Installer) Uninstall(tools []Tool, d *Deps) error
- func (i *Installer) Verify(t Tool, d *Deps) error
- type Mode
- type Tool
Constants ¶
This section is empty.
Variables ¶
var GoVersion string
var Tools = []Tool{ {Mode: GoInstall, Name: "tinygoinstall", Label: "TinyGo", Source: "github.com/tinywasm/tinygo/cmd/tinygoinstall", ModuleVersion: "v0.0.7", Version: "0.40.1", VerifyBinary: "tinygo", Required: true}, {Mode: Binary, Name: "tinywasm", Source: "https://github.com/tinywasm/app", Version: "", Required: true}, }
Functions ¶
func DefaultDownload ¶
DefaultDownload is a production implementation of Download
func ResolveTools ¶ added in v0.0.25
ResolveTools translates the -tools flag value into optional tool indices.
"" → no optional tools (required only) "all" → all optional tools "a,b" → optional tools whose Name matches
func RunWithSpinner ¶
RunWithSpinner runs fn printing a simple status line. Uses plain text output — no ANSI codes — for compatibility with PowerShell, Windows Terminal, and SSH sessions.
Types ¶
type Deps ¶
type Deps struct {
RunCmd func(name string, args ...string) ([]byte, error) // exec.Command
Download func(url string) ([]byte, error) // net/http GET
WriteFile func(path string, data []byte, perm os.FileMode) error // os.WriteFile
RemoveFile func(path string) error // os.Remove
LookPath func(name string) (string, error) // exec.LookPath
}
Deps — all external operations behind interfaces for testability
type InstallResult ¶
InstallResult holds counts for the summary line.
type Installer ¶
type Installer struct{}
func (*Installer) InstallAll ¶
func (ins *Installer) InstallAll(tools []Tool, selectedIdx []int, deps *Deps) InstallResult
InstallAll installs required tools + the optional tools at the given indices. Returns counts for summary output. On required tool failure, writes to stderr and exits.
func (*Installer) InstallBinary ¶
InstallBinary handles the installation of tools from GitHub releases.
func (*Installer) InstallGoInstall ¶
InstallGoInstall installs a tool via `go install source@moduleVersion`, then runs the installed binary with `-version t.Version` to perform the actual tool installation (e.g. tinygoinstall installs TinyGo).
func (*Installer) Uninstall ¶
Uninstall removes tools according to the UNINSTALL environment variable.
func (*Installer) Verify ¶
Verify checks if the tool is correctly installed and has the expected version. If VerifyBinary is set, it is used instead of Name to run the version check. Resolves the binary via LookPath first; on Windows also checks Scoop shims so verification works even when shims are not in the current process PATH.
type Tool ¶
type Tool struct {
Mode Mode
Name string // binary name used to invoke the tool
Label string // human-readable display name (shown during install); defaults to Name
Source string // module path (GoInstall) or GitHub repo (Binary)
ModuleVersion string // Go module version for go install (GoInstall only); defaults to "latest"
Version string // tool version to install and verify (e.g. TinyGo 0.40.1)
VerifyBinary string // binary to run for verification; defaults to Name if empty
Required bool // true = always install; false = prompt user
DependsOn string // "" = no dependency; "git" = requires git installed first
}