Documentation ¶
Overview ¶
Package configuration handles modifying, saving, and outputting the configuration file.
Index ¶
- type Configuration
- func (config *Configuration) Create(filePath string) (bool, error)
- func (config *Configuration) GetConfigDirPath() (string, error)
- func (config *Configuration) GetConfigFilePath() (string, error)
- func (config *Configuration) Init() error
- func (config *Configuration) Output() error
- func (config *Configuration) Parse() error
- func (config *Configuration) Save() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Configuration ¶
type Configuration struct { MailDropEmail string `json:"mailDropEmail"` GmailUsername string `json:"gmailUsername"` GmailPassword string `json:"gmailPassword"` }
Configuration represents the fields in the configuration file.
func (*Configuration) Create ¶ added in v0.2.1
func (config *Configuration) Create(filePath string) (bool, error)
Create is what creates the configuration file.
func (*Configuration) GetConfigDirPath ¶
func (config *Configuration) GetConfigDirPath() (string, error)
GetConfigDirPath retrieves the absolute path to the configuration directory in an OS independent way.
The configuration folder is at `~/.of`. If an error occurs, an empty string is returned as the path.
func (*Configuration) GetConfigFilePath ¶
func (config *Configuration) GetConfigFilePath() (string, error)
GetConfigFilePath retrieves the absolute path to the configuration file in an OS independent way.
The configuration file is at `~/.of/config.json`. If an error occurs, an empty string is returned as the path.
func (*Configuration) Init ¶
func (config *Configuration) Init() error
Init initializes the configuration file by creating the configuration folder at ~/.of/ and configuration file at ~/.of/config.json. It only creates these if they do not exist.
It is intended to be run when the application starts up to make sure that the config directory and file is created.
func (*Configuration) Output ¶
func (config *Configuration) Output() error
Output outputs the configuration file to stdout.
func (*Configuration) Parse ¶
func (config *Configuration) Parse() error
Parse parses the configuration file from `~/.of/config.json` and reads the fields into this Configuration.
func (*Configuration) Save ¶
func (config *Configuration) Save() error
Save saves the current state of this Configuration to `~/.of/config.json`.