Documentation
¶
Index ¶
- Constants
- Variables
- func PublicConfigOptions() []string
- type Config
- func (c *Config) EnsureConfigDir() (string, error)
- func (c *Config) GetCredentials() (Credentials, error)
- func (c *Config) RemoveCredentials() error
- func (c *Config) Reset() error
- func (c *Config) Set(key, val string) error
- func (c *Config) StoreCredentials(creds Credentials) error
- func (c *Config) Unset(key string) error
- type ConfigOutput
- type Credentials
Constants ¶
const DefaultConfigDir = "~/.config/ghost"
Variables ¶
var BuildTime = "unknown"
var ErrNotLoggedIn = errors.New("not logged in")
var GitCommit = "unknown"
var Version = "dev"
These variables are set at build time via ldflags in the GoReleaser pipeline for production releases. Default values are used for local development builds.
Functions ¶
func PublicConfigOptions ¶
func PublicConfigOptions() []string
Types ¶
type Config ¶
type Config struct {
APIURL string `mapstructure:"api_url"`
Analytics bool `mapstructure:"analytics"`
Color bool `mapstructure:"color"`
DocsMCPURL string `mapstructure:"docs_mcp_url"`
FunctionTools bool `mapstructure:"function_tools"`
Keyring bool `mapstructure:"keyring"`
ReadOnly bool `mapstructure:"read_only"`
ReleasesURL string `mapstructure:"releases_url"`
UIQueryHistoryLimit int `mapstructure:"ui_query_history_limit"`
VersionCheck bool `mapstructure:"version_check"`
ConfigDir string `mapstructure:"-"`
// contains filtered or unexported fields
}
func Load ¶
Load creates a new Config instance. The provided flag set is used to bind CLI flags (analytics, color, version-check) so they override file/env values, and to resolve the effective config directory (via the config-dir flag).
func (*Config) EnsureConfigDir ¶ added in v0.27.0
EnsureConfigDir creates the config directory if it does not already exist and returns the path to the config file within it.
func (*Config) GetCredentials ¶
func (c *Config) GetCredentials() (Credentials, error)
GetCredentials retrieves stored credentials (OAuth token or API key + space ID).
func (*Config) RemoveCredentials ¶
RemoveCredentials removes stored credentials from keyring and file fallback. When Keyring is disabled, the keyring is left untouched so that a logout in one config dir doesn't wipe credentials shared by another.
func (*Config) StoreCredentials ¶
func (c *Config) StoreCredentials(creds Credentials) error
StoreCredentials stores credentials (either an OAuth token or API key, plus space ID).
type ConfigOutput ¶
type ConfigOutput struct {
APIURL *string `mapstructure:"api_url" json:"api_url,omitempty"`
Analytics *bool `mapstructure:"analytics" json:"analytics,omitempty"`
Color *bool `mapstructure:"color" json:"color,omitempty"`
DocsMCPURL *string `mapstructure:"docs_mcp_url" json:"docs_mcp_url,omitempty"`
FunctionTools *bool `mapstructure:"function_tools" json:"function_tools,omitempty"`
Keyring *bool `mapstructure:"keyring" json:"keyring,omitempty"`
ReadOnly *bool `mapstructure:"read_only" json:"read_only,omitempty"`
ReleasesURL *string `mapstructure:"releases_url" json:"releases_url,omitempty"`
UIQueryHistoryLimit *int `mapstructure:"ui_query_history_limit" json:"ui_query_history_limit,omitempty"`
VersionCheck *bool `mapstructure:"version_check" json:"version_check,omitempty"`
ConfigDir string `mapstructure:"-" json:"-"`
// contains filtered or unexported fields
}
func LoadForOutput ¶
func LoadForOutput(configDir string, env bool, all bool) (*ConfigOutput, error)
LoadForOutput loads config values for display purposes using a fresh viper instance, independent of CLI flags and global state.
type Credentials ¶
type Credentials struct {
APIKey string `json:"api_key,omitempty"`
SpaceID string `json:"project_id"`
Token *oauth2.Token `json:"token,omitempty"`
}
Credentials represents the JSON structure for stored credentials. Legacy logins populate APIKey; new OAuth logins populate Token. The SpaceID field keeps the legacy "project_id" JSON key for backwards compatibility with credentials stored by older CLI versions.