packagemanagers

package
v0.0.0-...-ddee27d Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2023 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Package

type Package struct {
	Name             string
	InstalledVersion *Version
	LatestVersion    *Version
}

Package represents a package that is managed by a package manager.

func NewPackage

func NewPackage(name string, installedVersion *Version, latestVersion *Version) *Package

NewPackage creates a new instance of Package.

type PackageManager

type PackageManager interface {
	// Name returns the name of the package manager.
	Name() string

	// IsSupported returns whether the package manager is supported on the current machine.
	IsSupported() bool

	// IsInstalled returns whether the package manager is installed.
	IsInstalled() (bool, error)

	// Install installs the package manager.
	Install() error

	// Update updates the package manager.
	Update() error

	// Uninstall uninstalls the package manager.
	Uninstall() error

	// InstalledPackages returns a slice containing information about all packages that are installed.
	InstalledPackages() ([]*Package, error)

	// InstallPackage installs the package of the given name. If a version is given, that specific version of the
	// package is installed. Otherwise, the latest version is installed.
	//
	// It takes the following parameters:
	//   - packageName: The name of the package to install.
	// 	 - version: The version of the package to install. If nil, the latest version is installed.
	//
	// It returns the version of the package that was installed.
	InstallPackage(packageName string, version *Version) (*Version, error)

	// UpdatePackage updates the package of the given name. If a version is given, that specific version of the package
	// is installed. Otherwise, the latest version is installed.
	//
	// It takes the following parameters:
	//   - packageName: The name of the package to install.
	// 	 - version: The version of the package to install. If nil, the latest version is installed.
	//
	// It returns the version of the package that was installed.
	UpdatePackage(packageName string, version *Version) (*Version, error)

	// UninstallPackage uninstalls the package of the given name.
	UninstallPackage(packageName string) error
}

PackageManager represents a package manager that is supported by Familiar.sh.

type PackageManagerRegistry

type PackageManagerRegistry map[string]PackageManager

func NewPackageManagerRegistry

func NewPackageManagerRegistry(scoopPackageManager *ScoopPackageManager) PackageManagerRegistry

NewPackageManagerRegistry returns a new instance of PackageManagerRegistry.

func (PackageManagerRegistry) GetAllPackageManagers

func (packageManagerRegistry PackageManagerRegistry) GetAllPackageManagers() []PackageManager

GetAllPackageManagers returns a slice containing all package managers.

func (PackageManagerRegistry) GetPackageManager

func (packageManagerRegistry PackageManagerRegistry) GetPackageManager(packageManagerName string) (PackageManager,
	error)

GetPackageManager returns the package manager with the given name, if it exists.

It takes the following parameters:

  • packageManagerName: The name of the package manager.

type ScoopPackageManager

type ScoopPackageManager struct {
	// contains filtered or unexported fields
}

ScoopPackageManager implements the PackageManager interface for the Scoop package manager.

func NewScoopPackageManager

func NewScoopPackageManager(operatingSystemService *system.OperatingSystemService,
	shellCommandService *system.ShellCommandService) *ScoopPackageManager

NewScoopPackageManager returns a new instance of ScoopPackageManager.

func (*ScoopPackageManager) Install

func (scoopPackageManager *ScoopPackageManager) Install() error

Install installs the package manager.

func (*ScoopPackageManager) InstallPackage

func (scoopPackageManager *ScoopPackageManager) InstallPackage(packageName string, version *Version) (*Version, error)

InstallPackage installs the package of the given name. If a version is given, that specific version of the package is installed. Otherwise, the latest version is installed.

It returns the version of the package that was installed.

func (*ScoopPackageManager) InstalledPackages

func (scoopPackageManager *ScoopPackageManager) InstalledPackages() ([]*Package, error)

InstalledPackages returns a slice containing information about all packages that are installed.

func (*ScoopPackageManager) IsInstalled

func (scoopPackageManager *ScoopPackageManager) IsInstalled() (bool, error)

IsInstalled returns true if the package manager is installed.

func (*ScoopPackageManager) IsSupported

func (scoopPackageManager *ScoopPackageManager) IsSupported() bool

IsSupported returns whether the package manager is supported on the current machine.

func (*ScoopPackageManager) Name

func (scoopPackageManager *ScoopPackageManager) Name() string

Name returns the name of the package manager.

func (*ScoopPackageManager) Uninstall

func (scoopPackageManager *ScoopPackageManager) Uninstall() error

Uninstall uninstalls the package manager.

func (*ScoopPackageManager) UninstallPackage

func (scoopPackageManager *ScoopPackageManager) UninstallPackage(packageName string) error

UninstallPackage uninstalls the package of the given name.

func (*ScoopPackageManager) Update

func (scoopPackageManager *ScoopPackageManager) Update() error

Update updates the package manager.

func (*ScoopPackageManager) UpdatePackage

func (scoopPackageManager *ScoopPackageManager) UpdatePackage(packageName string, version *Version) (*Version, error)

UpdatePackage updates the package of the given name. If a version is given, that specific version of the package is installed. Otherwise, the latest version is installed.

It returns the version of the package that was installed.

type Version

type Version struct {
	VersionString string
}

Version represents a version of a package or package manager.

func NewVersion

func NewVersion(versionString string) *Version

NewVersion creates a new instance of Version.

func (*Version) IsEqualTo

func (version *Version) IsEqualTo(otherVersion *Version) bool

IsEqualTo returns whether the version is equal to the other version.

func (*Version) IsGreaterThan

func (version *Version) IsGreaterThan(otherVersion *Version) bool

IsGreaterThan returns whether the version is greater than the other version.

func (*Version) IsLessThan

func (version *Version) IsLessThan(otherVersion *Version) bool

IsLessThan returns whether the version is less than the other version.

func (*Version) String

func (version *Version) String() string

String returns the string representation of the version.

Jump to

Keyboard shortcuts

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