config

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package config manages persistent configuration and token storage for strava-cli.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dir

func Dir() (string, error)

Dir returns the path to the config directory (~/.config/strava-cli/). The STRAVA_CONFIG_DIR environment variable overrides the default location; set it in tests to avoid touching the real config on disk.

func Save

func Save(cfg *Config) error

Save writes the config to disk, creating the directory if needed.

Types

type Config

type Config struct {
	ClientID     string       `json:"client_id"`
	ClientSecret string       `json:"client_secret"`
	RedirectURI  string       `json:"redirect_uri,omitempty"`
	Tokens       Tokens       `json:"tokens,omitempty"`
	PendingAuth  *PendingAuth `json:"pending_auth,omitempty"`
}

Config is the full persisted configuration.

func Load

func Load() (*Config, error)

Load reads config from disk. Returns an empty Config if the file doesn't exist yet.

type PendingAuth

type PendingAuth struct {
	State       string `json:"state"`
	RedirectURI string `json:"redirect_uri"`
	ExpiresAt   int64  `json:"expires_at"` // Unix timestamp
}

PendingAuth holds state between step 1 and step 2 of a remote (two-step) login.

type Tokens

type Tokens struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	ExpiresAt    int64  `json:"expires_at"` // Unix timestamp
	TokenType    string `json:"token_type,omitempty"`
}

Tokens holds the OAuth2 token pair and metadata.

Jump to

Keyboard shortcuts

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