config

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 3 Imported by: 0

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

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

type Lists map[string][]string

Lists maps a list name to its SKUs, e.g. {"diarista": ["134", "62"]}.

func (Lists) Add

func (l Lists) Add(name, sku string) bool

Add appends a SKU, reporting false if it was already present.

func (Lists) Remove

func (l Lists) Remove(name, sku string) bool

Remove deletes a SKU, reporting false if it was not present.

type Store

type Store struct {
	Name string
}

Store scopes every config path to one store.

func (Store) CredentialsPath

func (s Store) CredentialsPath() string

func (Store) Dir

func (s Store) Dir() string

func (Store) ListsPath

func (s Store) ListsPath() string

func (Store) Load

func (s Store) Load() (*Config, error)

func (Store) LoadCredentials

func (s Store) LoadCredentials() (*Credentials, error)

func (Store) LoadLists

func (s Store) LoadLists() (Lists, error)

LoadLists returns an empty, usable map when no lists file exists, because callers Add to the result directly.

func (Store) Path

func (s Store) Path() string

func (Store) PendingAuthPath

func (s Store) PendingAuthPath() string

func (Store) Save

func (s Store) Save(cfg *Config) error

func (Store) SaveCredentials

func (s Store) SaveCredentials(c *Credentials) error

func (Store) SaveLists

func (s Store) SaveLists(l Lists) error

Jump to

Keyboard shortcuts

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