toolsync

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadTool

func DownloadTool(tool ToolDef, platform Platform, destDir string, progress func(pct float64)) error

DownloadTool downloads a tool binary from the registry.

func DownloadToolWithContext

func DownloadToolWithContext(ctx context.Context, tool ToolDef, platform Platform, destDir string, progress func(pct float64)) error

DownloadToolWithContext downloads a tool binary from the registry with context support.

func IsToolInstalled

func IsToolInstalled(destDir, toolName string) bool

IsToolInstalled checks if a tool binary exists at the expected path.

func SyncAll

func SyncAll(tools []ToolDef, platform Platform, destDir string, onProgress func(tool string, pct float64)) error

SyncAll downloads all tools, skipping those already installed unless forced.

func SyncAllWithContext

func SyncAllWithContext(ctx context.Context, tools []ToolDef, platform Platform, destDir string, onProgress func(tool string, pct float64)) error

SyncAllWithContext downloads all tools with context support, skipping those already installed unless forced.

func ToolBinPath

func ToolBinPath(destDir, toolName string) string

ToolBinPath returns the expected path to a tool binary.

Types

type Platform

type Platform struct {
	OS   string // darwin, linux, windows
	Arch string // amd64, arm64
}

Platform represents the target OS and architecture for tool downloads.

func DetectPlatform

func DetectPlatform() Platform

DetectPlatform returns the current runtime platform.

func (Platform) String

func (p Platform) String() string

String returns the platform string in the format "os_arch" (e.g., "darwin_arm64").

func (Platform) Validate

func (p Platform) Validate() error

Validate checks if the OS/Arch combination is supported.

type ToolDef

type ToolDef struct {
	Name        string            // Tool name (e.g., "templ")
	Version     string            // Pinned version
	URLTemplate string            // URL template with {{.OS}}, {{.Arch}}, {{.Version}} placeholders
	BinaryName  string            // Expected binary filename after extraction
	IsArchive   bool              // true if download is tar.gz/zip that needs extraction
	Checksums   map[string]string // platform string -> SHA256 hex (e.g., "darwin_arm64" -> "abc123...")
	OSMap       map[string]string // optional: runtime OS -> tool OS name (e.g., "darwin" -> "macos")
	ArchMap     map[string]string // optional: runtime Arch -> tool arch name (e.g., "amd64" -> "x64")
}

ToolDef defines a downloadable tool with version, URL pattern, and checksums.

func DefaultRegistry

func DefaultRegistry() []ToolDef

DefaultRegistry returns the tool definitions for all supported tools.

func FindTool

func FindTool(name string) (*ToolDef, bool)

FindTool looks up a tool by name in the registry.

Jump to

Keyboard shortcuts

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