Documentation
¶
Overview ¶
Package config manages application configuration
Index ¶
- func EnsureEnvFile() error
- func GetCFHandle() string
- func GetEnvFilePath() (string, error)
- func GetWorkspacePath() string
- func Init(workspacePath string) error
- func MigrateFromLegacy() (bool, error)
- func SaveCredentials(creds *Credentials) error
- func Set(key string, value interface{}) error
- func SetCFHandle(handle string) error
- func SetDailyGoal(goal int) error
- func SetDifficulty(min, max int) error
- func SetWorkspacePath(path string) error
- type Config
- type Credentials
- func (c *Credentials) CFClearanceExpiresIn() time.Duration
- func (c *Credentials) GetCFClearanceStatus() string
- func (c *Credentials) HasHandle() bool
- func (c *Credentials) HasSessionCookies() bool
- func (c *Credentials) IsAPIConfigured() bool
- func (c *Credentials) IsCFClearanceValid() bool
- func (c *Credentials) IsReadyForSubmission() bool
- func (c *Credentials) SetCFClearance(clearance, userAgent string, expiresAt time.Time)
- type DifficultyRange
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureEnvFile ¶
func EnsureEnvFile() error
EnsureEnvFile creates the .env file if it doesn't exist
func GetEnvFilePath ¶
GetEnvFilePath returns the path to the .env file
func MigrateFromLegacy ¶
MigrateFromLegacy migrates config from ~/.dsaprep to ~/.cf Returns true if migration was performed
func SaveCredentials ¶
func SaveCredentials(creds *Credentials) error
SaveCredentials saves credentials to the .env file
func SetWorkspacePath ¶
SetWorkspacePath sets the workspace path
Types ¶
type Config ¶
type Config struct {
// Codeforces settings
CFHandle string `mapstructure:"cf_handle"`
// Practice settings
Difficulty DifficultyRange `mapstructure:"difficulty"`
DailyGoal int `mapstructure:"daily_goal"`
// Paths
WorkspacePath string `mapstructure:"workspace_path"`
}
Config holds the application configuration
type Credentials ¶
type Credentials struct {
// API authentication
APIKey string
APISecret string
CFHandle string
// Session cookies (extracted from browser)
JSESSIONID string // JSESSIONID cookie for CF session
CE7Cookie string // 39ce7 cookie for CF session
// Cloudflare bypass
CFClearance string // cf_clearance cookie value
CFClearanceExpires int64 // Unix timestamp when cf_clearance expires
CFClearanceUA string // User-Agent tied to cf_clearance (MUST match)
}
Credentials holds CF API and cookie-based web credentials
func LoadCredentials ¶
func LoadCredentials() (*Credentials, error)
LoadCredentials loads credentials from the .env file
func (*Credentials) CFClearanceExpiresIn ¶
func (c *Credentials) CFClearanceExpiresIn() time.Duration
CFClearanceExpiresIn returns time until cf_clearance expires (negative if expired)
func (*Credentials) GetCFClearanceStatus ¶
func (c *Credentials) GetCFClearanceStatus() string
GetCFClearanceStatus returns a human-readable status string
func (*Credentials) HasHandle ¶
func (c *Credentials) HasHandle() bool
HasHandle returns true if CF handle is set
func (*Credentials) HasSessionCookies ¶
func (c *Credentials) HasSessionCookies() bool
HasSessionCookies returns true if session cookies are set
func (*Credentials) IsAPIConfigured ¶
func (c *Credentials) IsAPIConfigured() bool
IsAPIConfigured returns true if API credentials are set
func (*Credentials) IsCFClearanceValid ¶
func (c *Credentials) IsCFClearanceValid() bool
IsCFClearanceValid returns true if cf_clearance cookie is set and not expired
func (*Credentials) IsReadyForSubmission ¶
func (c *Credentials) IsReadyForSubmission() bool
IsReadyForSubmission returns true if we have everything needed to submit Requires: cf_clearance (valid) + session cookies + handle
func (*Credentials) SetCFClearance ¶
func (c *Credentials) SetCFClearance(clearance, userAgent string, expiresAt time.Time)
SetCFClearance sets the cf_clearance cookie with expiration and User-Agent
type DifficultyRange ¶
DifficultyRange represents min/max difficulty