config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AppName is the application name used in paths
	AppName = "osp"

	// ConfigFileName is the name of the config file
	ConfigFileName = "config.yaml"

	// StateFileName is the name of the state file
	StateFileName = "state.yaml"

	// DefaultDirMode is the default mode for directories
	DefaultDirMode = 0o700

	// DefaultFileMode is the default mode for files
	DefaultFileMode = 0o600
)

Variables

This section is empty.

Functions

func GetCacheHome added in v0.1.11

func GetCacheHome() string

GetCacheHome returns XDG_CACHE_HOME

func GetConfigDir added in v0.1.11

func GetConfigDir() string

GetConfigDir returns the configuration directory path

func GetConfigFile added in v0.1.11

func GetConfigFile() string

GetConfigFile returns the path to the config file

func GetConfigHome added in v0.1.11

func GetConfigHome() string

GetConfigHome returns XDG_CONFIG_HOME

func GetCurrentRepo added in v0.1.11

func GetCurrentRepo() (string, error)

GetCurrentRepo gets the current repository from state

func GetDataHome added in v0.1.11

func GetDataHome() string

GetDataHome returns XDG_DATA_HOME

func GetRepositories added in v0.1.11

func GetRepositories() ([]string, error)

GetRepositories gets the list of repositories from state

func GetStateDir added in v0.1.11

func GetStateDir() string

GetStateDir returns OSP state directory for storing program state

func GetStateFile added in v0.1.11

func GetStateFile() string

GetStateFile returns the path to the state file

func GetStateHome added in v0.1.11

func GetStateHome() string

GetStateHome returns XDG_STATE_HOME

func GetUsername added in v0.1.11

func GetUsername() (string, error)

GetUsername gets the username from the state file

func RemoveUsername added in v0.1.11

func RemoveUsername() error

RemoveUsername removes the username from state

func SaveCurrentRepo added in v0.1.11

func SaveCurrentRepo(current string) error

SaveCurrentRepo saves the current repository to state

func SaveRepositories added in v0.1.11

func SaveRepositories(repos []string) error

SaveRepositories saves the list of repositories to state

func SaveState added in v0.1.11

func SaveState(state *State) error

SaveState saves the application state

func SaveUsername added in v0.1.11

func SaveUsername(username string) error

SaveUsername saves the username to state file

Types

type Config

type Config struct{}

Config represents the application configuration

func Load

func Load(path string) (*Config, error)

Load loads the configuration from file

func (*Config) Save

func (c *Config) Save() error

Save saves the configuration to file

type State added in v0.1.11

type State struct {
	// Username for authentication
	Username string `yaml:"username,omitempty"`

	// Current repository
	Current string `yaml:"current,omitempty"`

	// List of repositories
	Repositories []string `yaml:"repositories,omitempty"`
}

State represents the application state

func LoadState added in v0.1.11

func LoadState() (*State, error)

LoadState loads the application state

Jump to

Keyboard shortcuts

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