userconfig

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package userconfig provides user machine-level configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Alter

func Alter(fn func(*Config)) error

Alter config, loading and saving after manipulation.

Types

type Config

type Config struct {
	// Team is the active team.
	Team string `json:"team"`

	// Teams is the user's active teams.
	Teams map[string]*Team `json:"teams"`
}

Config is the user configuration.

func (*Config) AddTeam

func (c *Config) AddTeam(t *Team)

AddTeam adds or replaces the given team.

func (*Config) Authenticated

func (c *Config) Authenticated() bool

Authenticated returns true if the user has an active team.

func (*Config) GetActiveTeam

func (c *Config) GetActiveTeam() *Team

GetActiveTeam returns the active team.

func (*Config) GetTeam

func (c *Config) GetTeam(id string) *Team

GetTeam returns a team by id or nil

func (*Config) GetTeams

func (c *Config) GetTeams() (teams []*Team)

GetTeams returns a list of teams.

func (*Config) Load

func (c *Config) Load() error

Load the configuration.

func (*Config) Save

func (c *Config) Save() error

Save the configuration.

type Team

type Team struct {
	// ID is the team identifier.
	ID string `json:"team"`

	// Email is the user's email.
	Email string `json:"email"`

	// Token is the access token.
	Token string `json:"token"`
}

Team is the user configuration for a given team.

func Require

func Require() (*Team, error)

Require requires authentication and returns the active team.

func (*Team) IsPersonal

func (t *Team) IsPersonal() bool

IsPersonal returns true if it is a personal team.

Jump to

Keyboard shortcuts

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