config

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: Apache-2.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DefaultConfigDir = "~/.config/ghost"

Variables

View Source
var BuildTime = "unknown"
View Source
var ErrNotLoggedIn = errors.New("not logged in")
View Source
var GitCommit = "unknown"
View Source
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"`
	ReadOnly     bool   `mapstructure:"read_only"`
	ReleasesURL  string `mapstructure:"releases_url"`
	ShareURL     string `mapstructure:"share_url"`
	VersionCheck bool   `mapstructure:"version_check"`

	ConfigDir string `mapstructure:"-"`
	// contains filtered or unexported fields
}

func Load

func Load(flags *pflag.FlagSet) (*Config, error)

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) GetCredentials

func (c *Config) GetCredentials() (Credentials, error)

GetCredentials retrieves stored credentials (OAuth token or API key + project ID).

func (*Config) RemoveCredentials

func (c *Config) RemoveCredentials() error

RemoveCredentials removes stored credentials from keyring and file fallback

func (*Config) Reset

func (c *Config) Reset() error

func (*Config) Set

func (c *Config) Set(key, val string) error

func (*Config) StoreCredentials

func (c *Config) StoreCredentials(creds Credentials) error

StoreCredentials stores credentials (either an OAuth token or API key, plus project ID).

func (*Config) Unset

func (c *Config) Unset(key string) error

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"`
	ReadOnly     *bool   `mapstructure:"read_only" json:"read_only,omitempty"`
	ReleasesURL  *string `mapstructure:"releases_url" json:"releases_url,omitempty"`
	ShareURL     *string `mapstructure:"share_url" json:"share_url,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"`
	ProjectID 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.

Jump to

Keyboard shortcuts

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