cli

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Copyright 2025 Tristan Isham. All rights reserved. Use of this source code is governed by the MIT license that can be found in the LICENSE file.

Copyright 2025 Tristan Isham. All rights reserved. Use of this source code is governed by the MIT license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingBundlePath     = errors.New("bundle download path not found")
	ErrUnsupportedSystem     = errors.New("unsupported system for Zig")
	ErrUnsupportedVersion    = errors.New("unsupported Zig version")
	ErrMissingInstallPathEnv = errors.New("env 'ZVM_INSTALL' is not set")
	ErrFailedUpgrade         = errors.New("failed to self-upgrade zvm")
	ErrInvalidVersionMap     = errors.New("invalid version map format")
	ErrInvalidInput          = errors.New("invalid input")
	// ErrDownloadFail is an an error when fetching Zig, or constructing a target URL to fetch Zig.
	ErrDownloadFail       = errors.New("failed to download Zig")
	ErrNoZlsVersion       = errors.New("zls release worker returned error")
	ErrMissingVersionInfo = errors.New("version info not found")
	ErrMissingShasum      = errors.New("shasum not found")
)
View Source
var ErrNoSettings = errors.New("settings.json not found")

Functions

func CanIUpgrade

func CanIUpgrade() (string, bool, error)

func ExtractBundle

func ExtractBundle(bundle, out string) error

func ExtractInstall

func ExtractInstall(input string) installRequest

func LoadMasterVersion

func LoadMasterVersion(zigMap *zigVersionMap) string

LoadMasterVersion takes a zigVersionMap and returns the master disto's version if it's present. If it's not, this function returns an empty string.

Types

type GithubRelease

type GithubRelease struct {
	CreatedAt       time.Time `json:"created_at"`
	PublishedAt     time.Time `json:"published_at"`
	TargetCommitish string    `json:"target_commitish"`
	Name            string    `json:"name"`
	Body            string    `json:"body"`
	ZipballURL      string    `json:"zipball_url"`
	NodeID          string    `json:"node_id"`
	TagName         string    `json:"tag_name"`
	URL             string    `json:"url"`
	HTMLURL         string    `json:"html_url"`
	TarballURL      string    `json:"tarball_url"`
	AssetsURL       string    `json:"assets_url"`
	UploadURL       string    `json:"upload_url"`
	Assets          []struct {
		UpdatedAt          time.Time   `json:"updated_at"`
		CreatedAt          time.Time   `json:"created_at"`
		Label              interface{} `json:"label"`
		ContentType        string      `json:"content_type"`
		Name               string      `json:"name"`
		URL                string      `json:"url"`
		State              string      `json:"state"`
		NodeID             string      `json:"node_id"`
		BrowserDownloadURL string      `json:"browser_download_url"`
		Uploader           struct {
			FollowingURL      string `json:"following_url"`
			NodeID            string `json:"node_id"`
			GistsURL          string `json:"gists_url"`
			StarredURL        string `json:"starred_url"`
			GravatarID        string `json:"gravatar_id"`
			URL               string `json:"url"`
			HTMLURL           string `json:"html_url"`
			FollowersURL      string `json:"followers_url"`
			Login             string `json:"login"`
			Type              string `json:"type"`
			AvatarURL         string `json:"avatar_url"`
			SubscriptionsURL  string `json:"subscriptions_url"`
			OrganizationsURL  string `json:"organizations_url"`
			ReposURL          string `json:"repos_url"`
			EventsURL         string `json:"events_url"`
			ReceivedEventsURL string `json:"received_events_url"`
			ID                int    `json:"id"`
			SiteAdmin         bool   `json:"site_admin"`
		} `json:"uploader"`
		Size          int `json:"size"`
		DownloadCount int `json:"download_count"`
		ID            int `json:"id"`
	} `json:"assets"`
	Author struct {
		FollowingURL      string `json:"following_url"`
		NodeID            string `json:"node_id"`
		GistsURL          string `json:"gists_url"`
		StarredURL        string `json:"starred_url"`
		GravatarID        string `json:"gravatar_id"`
		URL               string `json:"url"`
		HTMLURL           string `json:"html_url"`
		FollowersURL      string `json:"followers_url"`
		Login             string `json:"login"`
		Type              string `json:"type"`
		AvatarURL         string `json:"avatar_url"`
		SubscriptionsURL  string `json:"subscriptions_url"`
		OrganizationsURL  string `json:"organizations_url"`
		ReposURL          string `json:"repos_url"`
		EventsURL         string `json:"events_url"`
		ReceivedEventsURL string `json:"received_events_url"`
		ID                int    `json:"id"`
		SiteAdmin         bool   `json:"site_admin"`
	} `json:"author"`
	ID         int  `json:"id"`
	Prerelease bool `json:"prerelease"`
	Draft      bool `json:"draft"`
}

type Settings

type Settings struct {
	VersionMapUrl      string `json:"versionMapUrl,omitempty"`    // Zig's version map URL
	ZlsVMU             string `json:"zlsVersionMapUrl,omitempty"` // ZLS's version map URL
	UseColor           bool   `json:"useColor"`
	AlwaysForceInstall bool   `json:"alwaysForceInstall"`
	// contains filtered or unexported fields
}

func (*Settings) NoColor

func (s *Settings) NoColor()

func (*Settings) ResetVersionMap

func (s *Settings) ResetVersionMap() error

func (*Settings) ResetZlsVMU added in v0.7.8

func (s *Settings) ResetZlsVMU() error

func (*Settings) SetColor

func (s *Settings) SetColor(answer bool)

func (*Settings) SetVersionMapUrl

func (s *Settings) SetVersionMapUrl(versionMapUrl string) error

func (*Settings) SetZlsVMU added in v0.7.8

func (s *Settings) SetZlsVMU(versionMapUrl string) error

func (*Settings) ToggleColor

func (s *Settings) ToggleColor()

func (*Settings) YesColor

func (s *Settings) YesColor()

type ZVM

type ZVM struct {
	Settings Settings
	// contains filtered or unexported fields
}

func Initialize

func Initialize() *ZVM

func (*ZVM) Clean

func (z *ZVM) Clean() error

func (*ZVM) GetInstalledVersions added in v0.7.6

func (z *ZVM) GetInstalledVersions() ([]string, error)

func (*ZVM) Install

func (z *ZVM) Install(version string, force bool) error

func (*ZVM) InstallZls

func (z *ZVM) InstallZls(requestedVersion string, compatMode string, force bool) error

func (ZVM) ListRemoteAvailable

func (z ZVM) ListRemoteAvailable() error

func (*ZVM) ListVersions

func (z *ZVM) ListVersions() error

func (*ZVM) Run added in v0.8.0

func (z *ZVM) Run(version string, cmd []string) error

Run the given Zig compiler with the provided arguments

func (*ZVM) SelectZlsVersion added in v0.7.7

func (z *ZVM) SelectZlsVersion(version string, compatMode string) (string, string, string, error)

func (*ZVM) Sync

func (z *ZVM) Sync() error

func (*ZVM) Uninstall

func (z *ZVM) Uninstall(ver string) error

func (*ZVM) Upgrade

func (z *ZVM) Upgrade() error

Upgrade will upgrade the system installation of ZVM. I wrote most of it before I remembered that GitHub has an API so expect major refactoring.

func (*ZVM) Use

func (z *ZVM) Use(ver string) error

type ZigOnlVersion

type ZigOnlVersion = map[string][]map[string]string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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