Documentation
¶
Overview ¶
Package config stores per-store CLI state under ~/.config/<store>/.
Every path is derived from the store name, so two store CLIs on the same machine can never read or clobber each other's state. Secrets never live here — passwords and tokens belong in the OS keyring. The one thing this package holds that is close to a secret is the login email, which is kept so an expired token can be refreshed without prompting.
Index ¶
- type Config
- type Credentials
- type Lists
- type Store
- func (s Store) CredentialsPath() string
- func (s Store) Dir() string
- func (s Store) ListsPath() string
- func (s Store) Load() (*Config, error)
- func (s Store) LoadCredentials() (*Credentials, error)
- func (s Store) LoadLists() (Lists, error)
- func (s Store) Path() string
- func (s Store) PendingAuthPath() string
- func (s Store) Save(cfg *Config) error
- func (s Store) SaveCredentials(c *Credentials) error
- func (s Store) SaveLists(l Lists) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
CEP string `json:"cep,omitempty"`
Street string `json:"street,omitempty"`
Number string `json:"number,omitempty"`
Complement string `json:"complement,omitempty"`
Neighborhood string `json:"neighborhood,omitempty"`
City string `json:"city,omitempty"`
State string `json:"state,omitempty"`
OrderFormID string `json:"orderFormId,omitempty"`
}
Config is the persisted delivery address and cart pointer.
type Credentials ¶
type Credentials struct {
Email string `json:"email,omitempty"`
}
Credentials holds the login email. The password lives in the OS keyring.
type Lists ¶
Lists maps a list name to its SKUs, e.g. {"diarista": ["134", "62"]}.
type Store ¶
type Store struct {
Name string
}
Store scopes every config path to one store.
func (Store) CredentialsPath ¶
func (Store) LoadCredentials ¶
func (s Store) LoadCredentials() (*Credentials, error)
func (Store) LoadLists ¶
LoadLists returns an empty, usable map when no lists file exists, because callers Add to the result directly.
func (Store) PendingAuthPath ¶
func (Store) SaveCredentials ¶
func (s Store) SaveCredentials(c *Credentials) error