config

package
v0.0.0-...-b3686c0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAliasNotFound is returned when the account alias does not exist
	ErrAliasNotFound = errors.New("alias does not exist")
	// ErrUnableLoadConfig is returned when the config cannot be loaded from config dir
	ErrUnableLoadConfig = errors.New("unable to load config from config directory")
	// ErrUnableSafeConfig is returned when the config cannot be safed to config dir
	ErrUnableSafeConfig = errors.New("unable to safe config from config directory")
	// ErrUnableLocateHomeDir is returned when the home dir cannot be located
	ErrUnableLocateHomeDir = errors.New("unable to locate home directory")
	// ErrInvalidArgument is returned when invalid arguments have been passed to function
	ErrInvalidArgument = errors.New("argument is invalid or was nil")
)

Functions

func GetConfigDir

func GetConfigDir() (string, error)

GetConfigDir constructs go-t client config folder.

func GetConfigPath

func GetConfigPath() (string, error)

GetConfigPath onstructs go-t client configuration path.

func IsConfigExists

func IsConfigExists() bool

IsConfigExists returns false if config doesn't exist.

func IsValidAlias

func IsValidAlias(alias string) bool

IsValidAlias Check if an account alias valid.

func SaveConfig

func SaveConfig(config *Config) error

SaveConfig saves the configuration file and returns error if any.

func SetConfigDir

func SetConfigDir(configDir string)

SetConfigDir sets a custom go-t client config folder.

Types

type AccountConfig

type AccountConfig struct {
	ConsumerKey    string `json:"consumerKey"`
	ConsumerSecret string `json:"consumerSecret"`
	AccessToken    string `json:"accessToken"`
	AccessSecret   string `json:"accessSecret"`
}

AccountConfig represents twitter app auth credentials

func GetAccountConfig

func GetAccountConfig(alias string) (*AccountConfig, error)

GetAccountConfig retrieves account specific configuration.

type Config

type Config struct {
	Version  string                   `json:"version"`
	Context  string                   `json:"context"`
	Accounts map[string]AccountConfig `json:"account"`
}

Config represents the cli config

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig loads the config file

func NewConfig

func NewConfig() *Config

NewConfig initializes a new config.

func (*Config) GetAccountByContext

func (c *Config) GetAccountByContext() (*AccountConfig, error)

GetAccountByContext retrieves account specific configuration.

func (*Config) GetAccountConfig

func (c *Config) GetAccountConfig(alias string) (*AccountConfig, error)

GetAccountConfig retrieves account specific configuration.

Jump to

Keyboard shortcuts

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