chopsticks

package module
v0.0.0-...-db9acaf Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2021 License: AGPL-3.0 Imports: 21 Imported by: 0

README

🥢 chopsticks [WIP]

an alternative cli for scoop

  • we are not about to replace scoop, but provide an alternative cli client, and API for gophers.
  • we won't handle deprecated properties
  • we are using manifest schema from https://github.com/lukesampson/scoop/pull/3518, although it has not been merged yet

roadmap

translate powershell to go <- now

by 0.1.0: this would be a could use cli application.

by 1.0.0: refactor, all API would be stable.

more friendly user experience.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BucketsDir = filepath.Join(ScoopDir, "buckets")
View Source
var CacheDir = getCacheDir()

CacheDir represents for downloaded cache dir

View Source
var ConfigFile = filepath.Join(getConfigHome(), "scoop", "config.json")

ConfigFile returns the path of scoop config file

View Source
var GlobalDir = getGlobalDir()

GlobalDir represents for Scoop Global dir

View Source
var ScoopDir = getScoopDir()

ScoopDir represents for Scoop base dir

Functions

func AddBucket

func AddBucket(name, repo string)

func CurrentVersion

func CurrentVersion(app string, isGlobal bool) (string, error)

CurrentVersion

func Error

func Error(a string)

func FindBucketDir

func FindBucketDir(name string) (string, error)

func FindBucketDirectory

func FindBucketDirectory(name string) string

func FindManifest

func FindManifest(app, bucket string)

func GetAppFilePath

func GetAppFilePath(app, file string) string

func GetArchitecture

func GetArchitecture() string

func GetHelperPath

func GetHelperPath(helper string) string

available helpers: 7zip, Lessmsi, Innounp, Dark, Aria2

func GetInstalledApps

func GetInstalledApps(isGlobal bool) ([]string, error)

func GetLocalBuckets

func GetLocalBuckets() ([]string, error)

func GetManifestPath

func GetManifestPath(app, bucket string) (string, error)

func HumanReadableFileSize

func HumanReadableFileSize(length int64) string

func Info

func Info(a string)

func LatestVersion

func LatestVersion(app, bucket string) (string, error)

LatestVersion get the version from bucket

func LatestVersionFromUrl

func LatestVersionFromUrl(url string) (string, error)

LatestVersionFromUrl get the latest version from url

func RmBucket

func RmBucket(name string)

func SanitaryPath

func SanitaryPath(path string) string

func SaveInstallInfo

func SaveInstallInfo(info InstallInfo, dir string) error

func SaveInstalledManifest

func SaveInstalledManifest(app, bucket, dir, url string)

func Success

func Success(a string)

func Warn

func Warn(a string)

Types

type AppStatus

type AppStatus struct {
	Installed     bool
	Version       string
	LatestVersion string
	Failed        bool
	Hold          bool
	Removed       bool
	Outdated      bool
	MissingDeps   []string
}

func GetAppStatus

func GetAppStatus(app string, isGlobal bool) (AppStatus, error)

type Autoupdate

type Autoupdate struct {
	URL          *StringOrArrayOfStrings                          `json:"url,omitempty"`
	Hash         *HashExtractionOrArrayOfHashExtractions          `json:"hash,omitempty"`
	ExtractDir   *StringOrArrayOfStrings                          `json:"extract_dir,omitempty"`
	ExtractTo    *StringOrArrayOfStrings                          `json:"extract_to,omitempty"`
	Installer    *AutoupdateInstaller                             `json:"installer,omitempty"`
	PreInstall   *StringOrArrayOfStrings                          `json:"pre_install,omitempty"`
	PostInstall  *StringOrArrayOfStrings                          `json:"post_install,omitempty"`
	EnvAddPath   *StringOrArrayOfStrings                          `json:"env_add_path,omitempty"`
	EnvSet       map[string]interface{}                           `json:"env_set,omitempty"`
	Psmodule     *The32BitPsmodule                                `json:"psmodule,omitempty"`
	Bin          *StringOrArrayOfStringsOrAnArrayOfArrayOfStrings `json:"bin,omitempty"`
	Shortcuts    [][]string                                       `json:"shortcuts,omitempty"`
	Persist      *StringOrArrayOfStringsOrAnArrayOfArrayOfStrings `json:"persist,omitempty"`
	Architecture *AutoupdateArchitecture                          `json:"architecture,omitempty"`
	Note         *StringOrArrayOfStrings                          `json:"note,omitempty"`
}

type AutoupdateArch

type AutoupdateArch struct {
	URL         *StringOrArrayOfStrings                          `json:"url,omitempty"`
	Hash        *HashExtractionOrArrayOfHashExtractions          `json:"hash,omitempty"`
	ExtractDir  *StringOrArrayOfStrings                          `json:"extract_dir,omitempty"`
	ExtractTo   *StringOrArrayOfStrings                          `json:"extract_to,omitempty"`
	Installer   *AutoupdateInstaller                             `json:"installer,omitempty"`
	PreInstall  *StringOrArrayOfStrings                          `json:"pre_install,omitempty"`
	PostInstall *StringOrArrayOfStrings                          `json:"post_install,omitempty"`
	EnvAddPath  *StringOrArrayOfStrings                          `json:"env_add_path,omitempty"`
	EnvSet      map[string]interface{}                           `json:"env_set,omitempty"`
	Psmodule    *The32BitPsmodule                                `json:"psmodule,omitempty"`
	Bin         *StringOrArrayOfStringsOrAnArrayOfArrayOfStrings `json:"bin,omitempty"`
	Shortcuts   [][]string                                       `json:"shortcuts,omitempty"`
	Persist     *StringOrArrayOfStringsOrAnArrayOfArrayOfStrings `json:"persist,omitempty"`
	Note        *StringOrArrayOfStrings                          `json:"note,omitempty"`
}

type AutoupdateArchitecture

type AutoupdateArchitecture struct {
	The32Bit *AutoupdateArch `json:"32bit,omitempty"`
	The64Bit *AutoupdateArch `json:"64bit,omitempty"`
}

type AutoupdateInstaller

type AutoupdateInstaller struct {
	File *string `json:"file,omitempty"`
}

type Checkver

type Checkver struct {
	CheckverClass *CheckverClass
	String        *string
}

func (*Checkver) MarshalJSON

func (x *Checkver) MarshalJSON() ([]byte, error)

func (*Checkver) UnmarshalJSON

func (x *Checkver) UnmarshalJSON(data []byte) error

type CheckverClass

type CheckverClass struct {
	Github    *string `json:"github,omitempty"`
	Jp        *string `json:"jp,omitempty"` // Same as 'jsonpath'
	Jsonpath  *string `json:"jsonpath,omitempty"`
	Re        *string `json:"re,omitempty"` // Same as 'regex'
	Regex     *string `json:"regex,omitempty"`
	Replace   *string `json:"replace,omitempty"` // Allows rearrange the regexp matches
	Reverse   *bool   `json:"reverse,omitempty"` // Reverse the order of regex matches
	URL       *string `json:"url,omitempty"`
	Useragent *string `json:"useragent,omitempty"`
	Xpath     *string `json:"xpath,omitempty"`
}

type Hash

type Hash struct {
	String      *string
	StringArray []string
}

func (*Hash) MarshalJSON

func (x *Hash) MarshalJSON() ([]byte, error)

func (*Hash) UnmarshalJSON

func (x *Hash) UnmarshalJSON(data []byte) error

type HashExtraction

type HashExtraction struct {
	Find     *string `json:"find,omitempty"` // Same as 'regex'
	Jp       *string `json:"jp,omitempty"`   // Same as 'jsonpath'
	Jsonpath *string `json:"jsonpath,omitempty"`
	Mode     *Mode   `json:"mode,omitempty"`
	Regex    *string `json:"regex,omitempty"`
	URL      *string `json:"url,omitempty"`
	Xpath    *string `json:"xpath,omitempty"`
}

type HashExtractionOrArrayOfHashExtractions

type HashExtractionOrArrayOfHashExtractions struct {
	HashExtraction      *HashExtraction
	HashExtractionArray []HashExtraction
}

func (*HashExtractionOrArrayOfHashExtractions) MarshalJSON

func (x *HashExtractionOrArrayOfHashExtractions) MarshalJSON() ([]byte, error)

func (*HashExtractionOrArrayOfHashExtractions) UnmarshalJSON

func (x *HashExtractionOrArrayOfHashExtractions) UnmarshalJSON(data []byte) error

type InstallInfo

type InstallInfo struct {
	URL          string `json:"url,omitempty"`
	Bucket       string `json:"bucket,omitempty"`
	Architecture string `json:"architecture,omitempty"`
	Hold         bool   `json:"hold,omitempty"`
}

InstallInfo 是安装好后,存在于 apps/version/ 下 ,描述当前应用,拥有以下字段: 从何处安装(url, bucket) 架构信息(architecture) 是否版本冻结(hold)

func GetInstallInfo

func GetInstallInfo(app, version string, isGlobal bool) (InstallInfo, error)

func UnmarshalInstallInfo

func UnmarshalInstallInfo(data []byte) (InstallInfo, error)

UnmarshalInstallInfo 将字节流形式的 `install.json` 转换成 InstallInfo 结构体

func (*InstallInfo) Marshal

func (r *InstallInfo) Marshal() ([]byte, error)

Marshal 将 InstallInfo 结构体转换为字节流

func (*InstallInfo) ToPrettyJson

func (r *InstallInfo) ToPrettyJson() (string, error)

ToPrettyJson 将 InstallInfo 信息以 pretty-print json 形式输出

type LicenseClass

type LicenseClass struct {
	Identifier string  `json:"identifier,omitempty"`
	URL        *string `json:"url,omitempty"`
}

type LicenseUnion

type LicenseUnion struct {
	LicenseClass *LicenseClass
	String       *string
}

func (*LicenseUnion) MarshalJSON

func (x *LicenseUnion) MarshalJSON() ([]byte, error)

func (*LicenseUnion) UnmarshalJSON

func (x *LicenseUnion) UnmarshalJSON(data []byte) error

type Manifest

type Manifest struct {
	Empty        *StringOrArrayOfStrings                          `json:"##,omitempty"` // A comment.
	Version      string                                           `json:"version,omitempty"`
	Homepage     *string                                          `json:"homepage,omitempty"`
	Description  *string                                          `json:"description,omitempty"`
	License      *LicenseUnion                                    `json:"license,omitempty"`
	URL          *StringOrArrayOfStrings                          `json:"url,omitempty"`
	Cookie       map[string]interface{}                           `json:"cookie,omitempty"` // Undocumented: Found at https://github.com/se35710/scoop-java/search?l=JSON&q=cookie
	Hash         *Hash                                            `json:"hash,omitempty"`
	Architecture *ManifestArchitecture                            `json:"architecture,omitempty"`
	ExtractDir   *StringOrArrayOfStrings                          `json:"extract_dir,omitempty"`
	ExtractTo    *StringOrArrayOfStrings                          `json:"extract_to,omitempty"`
	Innosetup    *bool                                            `json:"innosetup,omitempty"` // True if the installer InnoSetup based. Found in; https://github.com/lukesampson/scoop/search?l=JSON&q=innosetup
	Installer    *ManifestInstaller                               `json:"installer,omitempty"`
	Uninstaller  *Uninstaller                                     `json:"uninstaller,omitempty"`
	PreInstall   *StringOrArrayOfStrings                          `json:"pre_install,omitempty"`
	PostInstall  *StringOrArrayOfStrings                          `json:"post_install,omitempty"`
	EnvAddPath   *StringOrArrayOfStrings                          `json:"env_add_path,omitempty"`
	EnvSet       map[string]interface{}                           `json:"env_set,omitempty"`
	Psmodule     *ManifestPsmodule                                `json:"psmodule,omitempty"`
	Bin          *StringOrArrayOfStringsOrAnArrayOfArrayOfStrings `json:"bin,omitempty"`
	Shortcuts    [][]string                                       `json:"shortcuts,omitempty"`
	Persist      *StringOrArrayOfStringsOrAnArrayOfArrayOfStrings `json:"persist,omitempty"`
	Checkver     *Checkver                                        `json:"checkver,omitempty"`
	Autoupdate   *Autoupdate                                      `json:"autoupdate,omitempty"`
	Depends      *StringOrArrayOfStrings                          `json:"depends,omitempty"`
	Suggest      *Suggest                                         `json:"suggest,omitempty"`
	Notes        *StringOrArrayOfStrings                          `json:"notes,omitempty"`
}

func GetInstalledManifest

func GetInstalledManifest(app, version string, isGlobal bool) (Manifest, error)

func GetManifest

func GetManifest(app, bucket string) (Manifest, error)

func GetUrlManifest

func GetUrlManifest(url string) Manifest

func UnmarshalManifest

func UnmarshalManifest(data []byte) (Manifest, error)

func (*Manifest) Marshal

func (r *Manifest) Marshal() ([]byte, error)

func (*Manifest) ToPrettyJson

func (r *Manifest) ToPrettyJson() (string, error)

type ManifestArchitecture

type ManifestArchitecture struct {
	The32Bit *The32BitClass `json:"32bit,omitempty"`
	The64Bit *The32BitClass `json:"64bit,omitempty"`
}

type ManifestInstaller

type ManifestInstaller struct {
	Args   *StringOrArrayOfStrings `json:"args,omitempty"`
	File   *string                 `json:"file,omitempty"`
	Keep   *bool                   `json:"keep,omitempty"`
	Script *StringOrArrayOfStrings `json:"script,omitempty"`
}

type ManifestPsmodule

type ManifestPsmodule struct {
	Name *string `json:"name,omitempty"`
}

type Mode

type Mode string
const (
	Download    Mode = "download"
	Extract     Mode = "extract"
	Fosshub     Mode = "fosshub"
	JSON        Mode = "json"
	Metalink    Mode = "metalink"
	RDF         Mode = "rdf"
	Sourceforge Mode = "sourceforge"
	Xpath       Mode = "xpath"
)

type StringOrArrayOfStrings

type StringOrArrayOfStrings struct {
	String      *string
	StringArray []string
}

A comment.

func (*StringOrArrayOfStrings) MarshalJSON

func (x *StringOrArrayOfStrings) MarshalJSON() ([]byte, error)

func (*StringOrArrayOfStrings) UnmarshalJSON

func (x *StringOrArrayOfStrings) UnmarshalJSON(data []byte) error

type StringOrArrayOfStringsOrAnArrayOfArrayOfStrings

type StringOrArrayOfStringsOrAnArrayOfArrayOfStrings struct {
	String     *string
	UnionArray []StringOrArrayOfStrings
}

func (*StringOrArrayOfStringsOrAnArrayOfArrayOfStrings) MarshalJSON

func (*StringOrArrayOfStringsOrAnArrayOfArrayOfStrings) UnmarshalJSON

type Suggest

type Suggest struct {
}

type The32BitClass

type The32BitClass struct {
	URL         *StringOrArrayOfStrings                          `json:"url,omitempty"`
	Hash        *Hash                                            `json:"hash,omitempty"`
	ExtractDir  *StringOrArrayOfStrings                          `json:"extract_dir,omitempty"`
	ExtractTo   *StringOrArrayOfStrings                          `json:"extract_to,omitempty"`
	Installer   *ManifestInstaller                               `json:"installer,omitempty"`
	Uninstaller *Uninstaller                                     `json:"uninstaller,omitempty"`
	PreInstall  *StringOrArrayOfStrings                          `json:"pre_install,omitempty"`
	PostInstall *StringOrArrayOfStrings                          `json:"post_install,omitempty"`
	EnvAddPath  *StringOrArrayOfStrings                          `json:"env_add_path,omitempty"`
	EnvSet      map[string]interface{}                           `json:"env_set,omitempty"`
	Bin         *StringOrArrayOfStringsOrAnArrayOfArrayOfStrings `json:"bin,omitempty"`
	Shortcuts   [][]string                                       `json:"shortcuts,omitempty"`
	Checkver    *Checkver                                        `json:"checkver,omitempty"`
}

type The32BitPsmodule

type The32BitPsmodule struct {
	Name *string `json:"name,omitempty"`
}

type Uninstaller

type Uninstaller struct {
	Args   *StringOrArrayOfStrings `json:"args,omitempty"`
	File   *string                 `json:"file,omitempty"`
	Script *StringOrArrayOfStrings `json:"script,omitempty"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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