utils

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfigDirPath = filepath.Join(usr.HomeDir, ".air")
View Source
var ConfigFilePath = filepath.Join(ConfigDirPath, "aqi")

Functions

func CheckConfig

func CheckConfig(config *Config) error

func CheckConfigDirectory

func CheckConfigDirectory() error

CheckConfigDirectory checks if config directory `$HOME/.air` is present. If not present, atttempts to create one.

func CreateTable

func CreateTable(r aqi.Response, table *tablewriter.Table, all bool)

CreateTable creates table based on response data.

func FillTable

func FillTable(r aqi.Response, table *tablewriter.Table, all bool)

FillTable draws table to stdout based on response values from the API.

func SaveConfig

func SaveConfig(config Config) error

SaveConfig writes new/updated config to the config file.

func ShowSelectionMenu

func ShowSelectionMenu(stationNames []string, message string) ([]string, error)

ShowSelectionMenu renders the selection menu.

Types

type AirConfig

type AirConfig interface {
	// contains filtered or unexported methods
}

type Config

type Config struct {
	ApiKey   string              `yaml:"apiKey,omitempty"`
	Stations map[string]Stations `yaml:"stations,omitempty"`
}

Config store configuration for the CLI.

func GetCurrentConfig

func GetCurrentConfig(config *Config) (*Config, error)

func NewConfig

func NewConfig() *Config

func (*Config) UpdateApiKey

func (c *Config) UpdateApiKey(newKey string)

type Stations

type Stations struct {
	StationName string `yaml:"stationName,omitempty"`
	UID         int    `yaml:"uid,omitempty"`
	SearchQuery string `yaml:"searchQuery,omitempty"`
}

Stations store data related to each station.

Jump to

Keyboard shortcuts

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