config

package
v0.0.0-...-674ef51 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Path to the config file
	Path         = filepath.Join(dir, filename)
	Icons        = cfg.Icons
	Cache        = cfg.Cache
	CLI          = cfg.CLI
	Read         = cfg.Read
	Download     = cfg.Download
	TUI          = cfg.TUI
	Providers    = cfg.Providers
	Library      = cfg.Library
	Notification = cfg.Notification
)

Exported config

Functions

func BindPFlag

func BindPFlag(key string, flag *pflag.Flag)

BindPFlag binds a pflag to a key.

Wrapper of viper.BindPFlag. Panics on error.

func Default

func Default(key string) any

Default value for the key.

func Description

func Description(key string) string

Description of the key value.

func DownloadOptions

func DownloadOptions() libmangal.DownloadOptions

DownloadOptions constructs the libmangal.DownloadOptions populated by the Config.

func Exists

func Exists(key string) bool

Exists if there is a registered key.

func Get

func Get(key string) any

Get value of the key.

Wrapper of viper.Get.

func Init

func Init()

Init initializes viper with the desired config (viper) options

func Keys

func Keys() []string

Keys returns all the registered keys.

func Load

func Load(path string) error

Load the config file and validates all config keys.

If path is empty, it will try to load from xdg.ConfigHome then from xdg.Home.

func ModeStrings

func ModeStrings() []string

ModeStrings returns a slice of all String values of the enum

func ReadOptions

func ReadOptions() libmangal.ReadOptions

func Set

func Set(key string, value any) error

Set a value for the key.

Wrapper of viper.Set.

func SetDefault

func SetDefault(key string, value any) error

SetDefault sets a default value for the key.

Wrapper of viper.SetDefault.

func Validate

func Validate(key string, value any) error

Validate the value for a the registered key.

func Write

func Write() error

Write current configuration to disk (to the set config directory/file).

Tries to write to the first path available.

Types

type Mode

type Mode uint8
const (
	ModeNone Mode = iota + 1
	ModeTUI
	ModeWeb
	ModeScript
	ModeInline
)

func ModeString

func ModeString(s string) (Mode, error)

ModeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func ModeValues

func ModeValues() []Mode

ModeValues returns all values of the enum

func (Mode) IsAMode

func (i Mode) IsAMode() bool

IsAMode returns "true" if the value is listed in the enum definition. "false" otherwise

func (Mode) MarshalJSON

func (i Mode) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for Mode

func (Mode) MarshalText

func (i Mode) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for Mode

func (Mode) MarshalYAML

func (i Mode) MarshalYAML() (interface{}, error)

MarshalYAML implements a YAML Marshaler for Mode

func (Mode) String

func (i Mode) String() string

func (*Mode) UnmarshalJSON

func (i *Mode) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for Mode

func (*Mode) UnmarshalText

func (i *Mode) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for Mode

func (*Mode) UnmarshalYAML

func (i *Mode) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements a YAML Unmarshaler for Mode

Jump to

Keyboard shortcuts

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