config

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 Config

type Config struct {
	Version         int                        `yaml:"version"`
	Files           []ConfiguredFile           `yaml:"files"`
	Scripts         []ConfiguredScript         `yaml:"scripts"`
	PackageManagers []ConfiguredPackageManager `yaml:"packageManagers"`
}

Config represents the contents of the config file.

func NewConfig

func NewConfig() *Config

NewConfig creates a new instance of Config.

func (*Config) AddPackage

func (config *Config) AddPackage(packageManagerName string, packageName string,
	packageVersion *packagemanagers.Version) error

AddPackage updates the Config to add the given version of the given package under the given package manager.

It throws an error under the following conditions:

  • The given package manager is not in the Config.
  • The given package is already in the Config under the given package manager.

It takes the following parameters:

  • packageManagerName: The name of the package manager.
  • packageName: The name of the package to add.
  • packageVersion: The version of the package to add.

func (*Config) AddPackageManager

func (config *Config) AddPackageManager(packageManagerName string, packageManagerRegistry packagemanagers.PackageManagerRegistry) error

AddPackageManager adds the given package manager to the Config.

It throws an error under the following conditions:

  • The given package manager is not a valid package manager.
  • The given package manager is already in the Config.

It takes the following parameters:

  • packageManagerName: The name of the package manager to add.
  • packageManagerRegistry: The package manager registry to use for validating the package manager name.

func (*Config) RemovePackage

func (config *Config) RemovePackage(packageManagerName string, packageName string) error

RemovePackage updates the Config to remove the given package under the given package manager.

It throws an error under the following conditions:

  • The given package manager is not in the Config.
  • The given package is not in the Config under the given package manager.

It takes the following parameters:

  • packageManagerName: The name of the package manager.
  • packageName: The name of the package to add.

func (*Config) RemovePackageManager

func (config *Config) RemovePackageManager(packageManagerName string) error

RemovePackageManager removes the given package manager from the Config. If the given package manager is not present in the Config, it throws an error.

It takes the following parameters:

  • packageManagerName: The name of the package manager to remove.

func (*Config) UpdatePackage

func (config *Config) UpdatePackage(packageManagerName string, packageName string,
	packageVersion *packagemanagers.Version) error

UpdatePackage updates the Config to change the given package under the given package manager to the given version.

It throws an error under the following conditions:

  • The given package manager is not in the Config.
  • The given package is not in the Config under the given package manager.
  • The given version is the same as the version of the package in the Config.

It takes the following parameters:

  • packageManagerName: The name of the package manager.
  • packageName: The name of the package to update.
  • packageVersion: The version of the package to update.

func (*Config) YamlString

func (config *Config) YamlString() (string, error)

YamlString returns the Config contents as a YAML string.

type ConfigService

type ConfigService struct {
}

ConfigService is a service that manages the shared configuration file.

func NewConfigService

func NewConfigService() *ConfigService

NewConfigService creates a new instance of ConfigService.

func (*ConfigService) GetConfig

func (configService *ConfigService) GetConfig() (*Config, error)

GetConfig returns the contents of the config file as a pointer to a Config struct.

func (*ConfigService) GetConfigLocation

func (configService *ConfigService) GetConfigLocation() (string, error)

GetConfigLocation returns the location of the shared configuration file, as stored in the "config_location" file in the XDG config directory. If the "config_location" file does not exist or is empty, an empty string is returned.

func (*ConfigService) SetConfig

func (configService *ConfigService) SetConfig(config *Config) error

SetConfig writes the given configuration to the config file as YAML.

It takes the following parameters:

  • config: The configuration to write to the file.

func (*ConfigService) SetConfigLocation

func (configService *ConfigService) SetConfigLocation(path string) error

SetConfigLocation writes the given path to the "config_location" file in the XDG config directory. If the directory of the file specified by the given path does not exist, or if the file is not a YAML file, an error is returned.

type ConfiguredFile

type ConfiguredFile struct {
	SourcePath       string                      `yaml:"sourcePath"`
	DestinationPath  string                      `yaml:"destinationPath,omitempty"`
	OperatingSystems []ConfiguredOperatingSystem `yaml:"operatingSystems,omitempty"`
}

ConfiguredFile represents a file managed by Familiar.sh.

type ConfiguredOperatingSystem

type ConfiguredOperatingSystem struct {
	Name            string `yaml:"name"`
	DestinationPath string `yaml:"destinationPath,omitempty"`
}

ConfiguredOperatingSystem represents an OS that a ConfiguredFile or ConfiguredScript is used in.

type ConfiguredPackage

type ConfiguredPackage struct {
	Name    string `yaml:"name"`
	Version string `yaml:"version"`
}

ConfiguredPackage represents a package installed by a specific package manager.

type ConfiguredPackageManager

type ConfiguredPackageManager struct {
	Name     string              `yaml:"name"`
	Packages []ConfiguredPackage `yaml:"packages"`
}

ConfiguredPackageManager represents a package manager installed by Familiar.sh.

type ConfiguredScript

type ConfiguredScript struct {
	SourcePath       string                      `yaml:"sourcePath"`
	OperatingSystems []ConfiguredOperatingSystem `yaml:"operatingSystems,omitempty"`
}

ConfiguredScript represents a script managed by Familiar.sh.

Jump to

Keyboard shortcuts

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