data

package
v0.0.0-...-6bb147f Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Port that the Pi-Hole API is defaulted to
	DefaultPort = 80
	// The default refresh rate of the data in seconds
	DefaultRefreshS = 1
	// The name of the configuration file
	ConfigFileName = "picli-config.json"
)

Constant values required by Pi-CLI

Variables

View Source
var LivePiCLIData = NewPiCLIData()

live updating config data used at runtime

View Source
var PICLISettings = NewSettings()

Store PiCLI settings

Functions

func ConfigFileExists

func ConfigFileExists() bool

Checks for the existence of a config file

func DeleteConfigFile

func DeleteConfigFile() bool

Delete the config file if it exists

func GetConfigFileLocation

func GetConfigFileLocation() string

Return the path to the config file

Types

type PiCLIData

type PiCLIData struct {
	// An instance of settings.Settings
	Settings *Settings
	// Remote address of the Pi-Hole
	FormattedAPIAddress string
	// The API key used to authenticate with the Pi-Hole
	APIKey string
	// The time that the last data poll was sent out to the Pi-Hole
	LastUpdated time.Time
	// If the keybinds screen is being shown or not
	ShowKeybindsScreen bool
	// String used to display the keybindings
	Keybinds []string
}

Stores the data needed by Pi-CLI during runtime

func NewPiCLIData

func NewPiCLIData() *PiCLIData

type Settings

type Settings struct {
	// The Pi-Hole's address
	PiHoleAddress string `json:"pi_hole_address"`
	// The port the Pi-Hole exposes that can be used for HTTP/S traffic
	PiHolePort int `json:"pi_hole_port"`
	// The number of seconds to wait between each data refresh
	RefreshS int `json:"refresh_s"`
	// API key used to authenticate with the Pi-Hole instance
	APIKey string `json:"api_key"`
}

Settings contains the current configuration options being used by Pi-CLI

func NewSettings

func NewSettings() *Settings

Return a new Settings instance

func (*Settings) APIKeyIsInFile

func (settings *Settings) APIKeyIsInFile() bool

Is API key stored in the config file? If not, off to the system keyring you go!

func (*Settings) LoadFromFile

func (settings *Settings) LoadFromFile()

Attempts to create a settings instance from a config file

func (*Settings) SaveToFile

func (settings *Settings) SaveToFile() error

Saves the current settings to a config file

Jump to

Keyboard shortcuts

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