config

package
v0.0.38 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2022 License: LGPL-3.0 Imports: 27 Imported by: 0

Documentation

Overview

Package config handles the user configations.

Index

Constants

View Source
const (
	ClearScreen = "\033c"
	ResetScreen = "\033[0m"
)
View Source
const NameFile = "config.yaml"

Variables

View Source
var (
	ErrEditorNil = errors.New("no suitable text editor can be found")
	ErrEditorRun = errors.New("editor cannot be run")
)
View Source
var (
	ErrConfigName = errors.New("viper config file cannot be empty")
	ErrWriter     = errors.New("writer cannot be nil")
)
View Source
var ErrEd = errors.New("there is no configuration file to edit")
View Source
var ErrExist = errors.New("a config file already exists")
View Source
var ErrStart = errors.New("setup start argument is out of range")

Functions

func Alert added in v0.0.38

func Alert(w io.Writer, list ...string) error

Alert returns writes list of missing settings in the config file.

func CmdPath added in v0.0.38

func CmdPath() string

func ConfigMissing added in v0.0.38

func ConfigMissing(w io.Writer, name, suffix string)

ConfigMissing writes an config file error notice.

func Create

func Create(w io.Writer, name string, ow bool) error

Create a named configuration file with an option to overwrite an existing file.

func CtrlC added in v0.0.33

func CtrlC(w io.Writer)

CtrlC intercepts Ctrl-C key combinations to exit out of the Setup.

func Delete

func Delete(w io.Writer, ask bool) error

Delete a configuration file.

func DoesExist added in v0.0.38

func DoesExist(w io.Writer, name, suffix string) error

DoesExist writes a how-to help message when a config file already exists.

func Edit

func Edit(w io.Writer) error

Edit a configuration file.

func Enabled

func Enabled() map[string]interface{}

Enabled returns all the Viper keys holding a value that are used. This will hide all unrecognized manual edits to the configuration file.

func Info

func Info(w io.Writer, style string) error

Info prints the content of a configuration file.

func InitDefaults

func InitDefaults()

InitDefaults initializes flag and configuration defaults.

func List

func List(w io.Writer) error

List and write all the available configurations.

func Load added in v0.0.38

func Load(w io.Writer, flag string) error

Load and reads a configuration file. The string argument should be the value of the hidden config flag.

func Location added in v0.0.33

func Location() string

Location returns the absolute path of the current configuration file and the status of any missing settings.

func Logo(w io.Writer) error

Logo writes a custom 256-color, ANSI logo for RetroTxt.

func Missing

func Missing() []string

Missing returns the settings that are not found in the configuration file. This could be due to new features being added after the file was generated or because of manual file edits.

func New added in v0.0.33

func New(w io.Writer, overwrite bool) error

New creates a new configuration file and writes the results.

func Path

func Path() string

Path returns the absolute path of the configuration file.

func Save added in v0.0.38

func Save(w io.Writer, name string) error

Save each of viper settings to the named file.

func Set

func Set(w io.Writer, name string) error

Set edits and saves a named setting within a configuration file. It also accepts numeric index values printed by List().

func Setup

func Setup(w io.Writer, start int) error

Setup walks through all the settings and saves them to the configuration file. The start argument can being the walkthrough at the provided question number or it can be left at 0.

func SortKeys added in v0.0.38

func SortKeys() []string

SortKeys list all the available configuration setting names sorted by hand.

func Tip added in v0.0.31

func Tip() get.Hints

Tip provides some brief help information of the configurations.

func Update

func Update(w io.Writer, name string, setup bool) error

Update edits and saves the named setting within a configuration file.

Types

type Formats

type Formats struct {
	Info [5]string
}

Formats the choices for command flags.

func Format

func Format() Formats

Format flag choices for the info command.

Directories

Path Synopsis
internal
get
set

Jump to

Keyboard shortcuts

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