config

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AllAccounts = "all"
)

Variables

This section is empty.

Functions

func CacheDir

func CacheDir() string

func ConfigDir

func ConfigDir() string

func Cover added in v0.2.0

func Cover() string

Cover is the art over the Imbox's Previously Seen, or "" for none.

It is stored here rather than read from HEY on purpose. The web app keeps a cover per box in its own table, but no client reads that: the iOS and Android apps each keep their own choice in device preferences, with their own set of presets, and never ask the server. This is the same decision, and it is the reason a cover set here does not show up on the web.

func HelpHidden added in v0.2.0

func HelpHidden() bool

HelpHidden reports whether the TUI's shortcut help is hidden.

func LastCalendarID added in v0.2.0

func LastCalendarID() int64

LastCalendarID is the calendar the last event was filed on, so the next new event opens on the same one. Somebody who keeps a work calendar and a personal one is nearly always adding to whichever they added to last, and the first in the list is a poor guess about which that is.

It lives here rather than on HEY for the reason Cover does: HEY serves no such preference, and making one up on the server for one client to read would be worse than remembering it locally.

func NonInteractiveEnv added in v0.2.0

func NonInteractiveEnv() bool

NonInteractiveEnv reports whether HEY_NONINTERACTIVE is set to a truthy value. When true, the CLI must not show interactive prompts regardless of TTY detection. This is an escape hatch for agents and harnesses that run the CLI under an allocated PTY (where stdio looks like a terminal) and want to avoid a prompt wedging the session — without forcing a machine output format the way --agent does.

func SaveCover added in v0.2.0

func SaveCover(preset string) error

SaveCover stores the Imbox's cover, leaving every other setting alone. An empty preset drops the key rather than writing a blank one.

func SaveHelpHidden added in v0.2.0

func SaveHelpHidden(hidden bool) error

SaveHelpHidden stores whether the TUI's shortcut help is hidden, leaving every other setting alone.

func SaveLastCalendarID added in v0.2.0

func SaveLastCalendarID(id int64) error

SaveLastCalendarID stores it, leaving every other setting alone.

func ScrubLegacyCredentials added in v0.2.0

func ScrubLegacyCredentials() error

ScrubLegacyCredentials removes migrated embedded credentials from the global config file. Call only after the credential store confirmed the save.

func StateDir

func StateDir() string

Types

type Config

type Config struct {
	BaseURL   string `json:"base_url"`
	AccountID string `json:"account_id,omitempty"`
	Onboarded bool   `json:"onboarded,omitempty"`
	// contains filtered or unexported fields
}

func Defaults added in v0.2.0

func Defaults() *Config

Defaults is the configuration before any file or environment is consulted: the fallback for commands that must run even when the global file is broken.

func Load

func Load() (*Config, error)

Load reads the effective configuration: defaults, the global file, a repository-local .hey/config.json found from the working directory, then the environment.

func LoadGlobal added in v0.2.0

func LoadGlobal() (*Config, error)

LoadGlobal reads the configuration without any repository-local file. It is for commands that run from an arbitrary working directory on the user's behalf — a desktop bar poller, say — where a checkout's config must neither redirect them nor trip the local-config trust gate.

func (*Config) LocalConfig

func (c *Config) LocalConfig() *LocalConfig

LocalConfig returns the discovered local configuration and its trust status.

func (*Config) SaveAccountID

func (c *Config) SaveAccountID(accountID string) error

SaveAccountID stores the default linked-account filter for the effective server without replacing settings for any other server.

func (*Config) SaveBaseURL

func (c *Config) SaveBaseURL(baseURL string) error

SaveBaseURL stores the global server URL while preserving account defaults for every server.

func (*Config) SaveOnboarded added in v0.2.0

func (c *Config) SaveOnboarded(onboarded bool) error

SaveOnboarded stores the onboarding flag in the global config so later logged-out runs of bare `hey` skip the full first-run wizard.

func (*Config) SetFromFlag

func (c *Config) SetFromFlag(key, value string) error

func (*Config) SourceOf

func (c *Config) SourceOf(key string) Source

func (*Config) TrustLocalConfig

func (c *Config) TrustLocalConfig() error

TrustLocalConfig trusts the current security-sensitive values in the discovered local configuration. A later change produces a different digest and requires trust again.

func (*Config) UntrustLocalConfig

func (c *Config) UntrustLocalConfig() error

UntrustLocalConfig removes trust for the discovered local configuration.

func (*Config) UntrustedLocalConfig

func (c *Config) UntrustedLocalConfig() *LocalConfig

UntrustedLocalConfig returns the local configuration when one of its values is effective for this invocation and the user has not trusted its current contents.

type LocalConfig

type LocalConfig struct {
	Path         string `json:"path"`
	BaseURL      string `json:"base_url,omitempty"`
	AccountID    string `json:"account_id,omitempty"`
	ServerOrigin string `json:"server_origin"`
	Digest       string `json:"digest"`
	Trusted      bool   `json:"trusted"`
}

LocalConfig describes the security-sensitive settings supplied by the nearest repository-local .hey/config.json file.

type OldConfig

type OldConfig struct {
	BaseURL       string `json:"base_url"`
	AccessToken   string `json:"access_token,omitempty"`
	RefreshToken  string `json:"refresh_token,omitempty"`
	TokenExpiry   int64  `json:"token_expiry,omitempty"`
	SessionCookie string `json:"session_cookie,omitempty"`
}

OldConfig represents the legacy config format with embedded credentials. Used only for migration.

func LoadOld

func LoadOld() (*OldConfig, error)

LoadOld reads the config file as the old format (with embedded credentials). Used only during migration.

type Source

type Source string
const (
	SourceDefault Source = "default"
	SourceGlobal  Source = "global"
	SourceLocal   Source = "local"
	SourceEnv     Source = "env"
	SourceFlag    Source = "flag"
)

type TrustedLocalConfig

type TrustedLocalConfig struct {
	Path         string `json:"path"`
	ServerOrigin string `json:"server_origin"`
	BaseURL      string `json:"base_url,omitempty"`
	AccountID    string `json:"account_id,omitempty"`
	Digest       string `json:"digest"`
}

TrustedLocalConfig identifies a repository-local configuration trusted by this user.

func TrustedLocalConfigs

func TrustedLocalConfigs() ([]TrustedLocalConfig, error)

TrustedLocalConfigs returns the local configurations trusted in user-level config.

Jump to

Keyboard shortcuts

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