Documentation
¶
Overview ¶
Package config manages CLI configuration and credentials.
Stores config and credentials per-server under the user's config directory (~/.config/life-ustc on Linux/Mac). Credentials are written atomically with 0600 permissions.
Index ¶
- Constants
- func Dir() string
- func GetDefaultServer() string
- func IsTokenExpired(cred *Credential) bool
- func RemoveCredentials(server string) (bool, error)
- func SaveConfig(cfg *Config) error
- func SaveCredentials(server string, cred *Credential) error
- func SetDefaultServer(server string) error
- type Config
- type Credential
Constants ¶
View Source
const ( AppName = "life-ustc" DefaultServer = "https://life-ustc.tiankaima.dev" )
Variables ¶
This section is empty.
Functions ¶
func GetDefaultServer ¶
func GetDefaultServer() string
func IsTokenExpired ¶
func IsTokenExpired(cred *Credential) bool
func RemoveCredentials ¶
func SaveConfig ¶
func SaveCredentials ¶
func SaveCredentials(server string, cred *Credential) error
func SetDefaultServer ¶
Types ¶
type Credential ¶
type Credential struct {
ClientID string `json:"client_id"`
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token,omitempty"`
TokenType string `json:"token_type"`
ExpiresAt float64 `json:"expires_at"`
Scope string `json:"scope,omitempty"`
Resource string `json:"resource,omitempty"`
}
func LoadCredentials ¶
func LoadCredentials(server string) (*Credential, error)
Click to show internal directories.
Click to hide internal directories.