config

package
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: May 29, 2022 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ConfigPath points to the config file
	ConfigPath = makeConfigPath()

	// output of prompt for password
	PasswordPromptOutput = os.Stderr

	// Password can be used to configure the random password generator
	Password = random.Password
)
View Source
var ReadLine = func() string {
	buf := bufio.NewReader(os.Stdin)
	line, err := buf.ReadString('\n')
	if err != nil {
		log.Fatalf("Failed to read line: %v", err)
	}

	return strings.TrimSpace(line)
}

ReadLine reads some input

Functions

func BackendConfig

func BackendConfig(ctx context.Context, name string)

BackendConfig runs the config helper for the backend if needed

func BackendListUnmarshal added in v0.1.9

func BackendListUnmarshal(out interface{}) error

func ChangePassword

func ChangePassword(name string) string

ChangePassword will query the user twice for the named password. If the same password is entered it is returned.

func Choose

func Choose(what string, defaults, help []string, newOk bool) string

Choose one of the defaults or type a new string if newOk is set

func ChooseBackend

func ChooseBackend() string

ChooseBackend chooses a backend name

func ChooseNumber

func ChooseNumber(what string, min, max int) int

ChooseNumber asks the user to enter a number between min and max inclusive prompting them with what.

func ChooseOption

func ChooseOption(o place.Option, name string) string

ChooseOption asks the user to choose an option

func Command

func Command(commands []string) byte

Command - choose one

func CommandDefault

func CommandDefault(commands []string, defaultIndex int) byte

CommandDefault - choose one. If return is pressed then it will chose the defaultIndex if it is >= 0

func Confirm

func Confirm(isDefault bool) bool

Confirm asks the user for Yes or No and returns true or false

If the user presses enter then the isDefault will be used

func CreateBackend

func CreateBackend(ctx context.Context, name string, provider string, keyValues rc.Params, doObscure, noObscure bool) error

CreateBackend create a new backend

func EditBackend

func EditBackend(ctx context.Context, ri *place.RegInfo, name string)

EditBackend gets the user to edit a backend

func EditConfig

func EditConfig(ctx context.Context)

EditConfig edits the config file interactively

func FileGet

func FileGet(section, key string, defaultVal ...string) string

FileGet gets the config key under section returning the default or empty string if not set.

It looks up defaults in the environment if they are present

func FileGetFlag

func FileGetFlag(section, key string) (string, bool)

FileGetFlag gets the config key under section returning the the value and true if found and or ("", false) otherwise

func FileSet

func FileSet(section, key, value string)

FileSet sets the key in section to value. It doesn't save the config file.

func GetConfigPath added in v0.1.14

func GetConfigPath() string

GetConfigPath get config path

func GetPassword

func GetPassword(prompt string) string

GetPassword asks the user for a password with the prompt given.

func LoadConfig

func LoadConfig()

LoadConfig loads the config file

func MustFindByName

func MustFindByName(name string) *place.RegInfo

MustFindByName finds the RegInfo for the backend name passed in or exits with a fatal error.

func NewBackend

func NewBackend(ctx context.Context, name string)

NewBackend make a new backend from its name

func NewBackendName

func NewBackendName() (name string)

NewBackendName asks the user for a name for a new backend

func OkBackend

func OkBackend(name string) bool

OkBackend prints the contents of the backend and ask if it is OK

func ReadPassword

func ReadPassword() string

ReadPassword reads a password without echoing it to the terminal.

func SetConfigPath added in v0.1.14

func SetConfigPath(path string) (err error)

SetConfigPath sets new config file path

Checks for empty string, os null device, or special path, all of which indicates in-memory config.

func SetValueAndSave

func SetValueAndSave(name, key, value string) (err error)

SetValueAndSave sets the key to the value and saves just that value in the config file. It loads the old config file in from disk first and overwrites the given value only.

func ShowBackend

func ShowBackend(name string)

ShowBackend shows the contents of the backend

func ShowBackends

func ShowBackends()

ShowBackends shows an overview of the config file

func UpdateBackend

func UpdateBackend(ctx context.Context, name string, keyValues rc.Params, doObscure, noObscure bool) error

UpdateBackend adds the keyValues passed in to the backend of name. keyValues should be key, value pairs.

Types

This section is empty.

Directories

Path Synopsis
Package flags contains enhanced versions of spf13/pflag flag routines which will read from the environment also.
Package flags contains enhanced versions of spf13/pflag flag routines which will read from the environment also.

Jump to

Keyboard shortcuts

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