config

package
v0.0.0-...-330e238 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2018 License: MIT Imports: 31 Imported by: 0

Documentation

Overview

Package config reads, writes and edits the config file and deals with command line flags

Index

Constants

View Source
const (

	// ConfigToken is the key used to store the token under
	ConfigToken = "token"

	// ConfigClientID is the config key used to store the client id
	ConfigClientID = "client_id"

	// ConfigClientSecret is the config key used to store the client secret
	ConfigClientSecret = "client_secret"

	// ConfigAuthURL is the config key used to store the auth server endpoint
	ConfigAuthURL = "auth_url"

	// ConfigTokenURL is the config key used to store the token server endpoint
	ConfigTokenURL = "token_url"

	// ConfigAutomatic indicates that we want non-interactive configuration
	ConfigAutomatic = "config_automatic"
)

Variables

View Source
var (

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

	// CacheDir points to the cache directory.  Users of this
	// should make a subdirectory and use MkdirAll() to create it
	// and any parents.
	CacheDir = makeCacheDir()
)

Global

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 Authorize

func Authorize(args []string)

Authorize is for remote authorization of headless machines.

It expects 1 or 3 arguments

rclone authorize "fs name"
rclone authorize "fs name" "client id" "client secret"

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 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 *fs.Option) string

ChooseOption asks the user to choose an option

func ChooseRemote

func ChooseRemote() string

ChooseRemote chooses a remote name

func Command

func Command(commands []string) byte

Command - choose one

func Confirm

func Confirm() bool

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

func CopyRemote

func CopyRemote(name string)

CopyRemote copies a config section

func CreateRemote

func CreateRemote(name string, provider string, keyValues []string) error

CreateRemote creates a new remote with name, provider and a list of parameters which are key, value pairs. If update is set then it adds the new keys rather than replacing all of them.

func DeleteRemote

func DeleteRemote(name string)

DeleteRemote gets the user to delete a remote

func Dump

func Dump() error

Dump dumps all the config as a JSON file

func EditConfig

func EditConfig()

EditConfig edits the config file interactively

func EditRemote

func EditRemote(fs *fs.RegInfo, name string)

EditRemote gets the user to edit a remote

func FileDeleteKey

func FileDeleteKey(section, key string) bool

FileDeleteKey deletes the config key in the config file. It returns true if the key was deleted, or returns false if the section or key didn't exist.

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 FileGetBool

func FileGetBool(section, key string, defaultVal ...bool) bool

FileGetBool gets the config key under section returning the default or false if not set.

It looks up defaults in the environment if they are present

func FileGetInt

func FileGetInt(section, key string, defaultVal ...int) int

FileGetInt gets the config key under section returning the default or 0 if not set.

It looks up defaults in the environment if they are present

func FileSections

func FileSections() []string

FileSections returns the sections in the config file including any defined by environment variables.

func FileSet

func FileSet(section, key, value string)

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

func GetPassword

func GetPassword(prompt string) string

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

func JSONListProviders

func JSONListProviders() error

JSONListProviders prints all the providers and options in JSON format

func LoadConfig

func LoadConfig()

LoadConfig loads the config file

func MustFindByName

func MustFindByName(name string) *fs.RegInfo

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

func MustObscure

func MustObscure(x string) string

MustObscure obscures a value, exiting with a fatal error if it failed

func MustReveal

func MustReveal(x string) string

MustReveal reveals an obscured value, exiting with a fatal error if it failed

func NewRemote

func NewRemote(name string)

NewRemote make a new remote from its name

func NewRemoteName

func NewRemoteName() (name string)

NewRemoteName asks the user for a name for a remote

func Obscure

func Obscure(x string) (string, error)

Obscure a value

This is done by encrypting with AES-CTR

func OkRemote

func OkRemote(name string) bool

OkRemote prints the contents of the remote and ask if it is OK

func PasswordRemote

func PasswordRemote(name string, keyValues []string) error

PasswordRemote adds the keyValues passed in to the remote of name. keyValues should be key, value pairs.

func ReadPassword

func ReadPassword() string

ReadPassword reads a password without echoing it to the terminal.

func RemoteConfig

func RemoteConfig(name string)

RemoteConfig runs the config helper for the remote if needed

func RenameRemote

func RenameRemote(name string)

RenameRemote renames a config section

func Reveal

func Reveal(x string) (string, error)

Reveal an obscured value

func SaveConfig

func SaveConfig()

SaveConfig saves configuration file. if configKey has been set, the file will be encrypted.

func SetPassword

func SetPassword()

SetPassword will allow the user to modify the current configuration encryption settings.

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 ShowConfig

func ShowConfig()

ShowConfig prints the (unencrypted) config options

func ShowConfigLocation

func ShowConfigLocation()

ShowConfigLocation prints the location of the config file in use

func ShowRemote

func ShowRemote(name string)

ShowRemote shows the contents of the remote

func ShowRemotes

func ShowRemotes()

ShowRemotes shows an overview of the config file

func UpdateRemote

func UpdateRemote(name string, keyValues []string) error

UpdateRemote adds the keyValues passed in to the remote of name. keyValues should be key, value pairs.

Types

This section is empty.

Directories

Path Synopsis
Package configflags defines the flags used by rclone.
Package configflags defines the flags used by rclone.
Package flags contains enahnced versions of spf13/pflag flag routines which will read from the environment also.
Package flags contains enahnced 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