config

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthMethodForHost added in v0.0.2

func AuthMethodForHost(host string) string

AuthMethodForHost returns the authentication method for a given host ("pat", "oauth", or "").

func ClientIDForHost added in v0.0.5

func ClientIDForHost(host string) string

ClientIDForHost returns the stored OAuth client ID for a given host.

func ConfigDir

func ConfigDir() string

ConfigDir returns the directory where config files are stored.

func DefaultHost

func DefaultHost() string

DefaultHost returns "gitlab.com" or the value of GITLAB_HOST env var.

func GetHostValue added in v0.0.5

func GetHostValue(host, key string) (string, error)

GetHostValue returns a per-host config value by key.

func HostKeys added in v0.0.5

func HostKeys() []string

HostKeys returns valid per-host config keys.

func Keys

func Keys() []string

Keys returns all valid config keys.

func SaveHosts

func SaveHosts(hosts HostsConfig) error

SaveHosts writes the hosts configuration to disk.

func SetHostValue added in v0.0.5

func SetHostValue(host, key, value string) error

SetHostValue sets a per-host config value by key.

func TokenForHost

func TokenForHost(host string) (string, string)

TokenForHost returns the authentication token for a given host.

Types

type Config

type Config struct {
	Editor    string `json:"editor,omitempty"`
	Pager     string `json:"pager,omitempty"`
	Browser   string `json:"browser,omitempty"`
	Protocol  string `json:"protocol,omitempty"` // "https" or "ssh"
	GitRemote string `json:"git_remote,omitempty"`
}

Config holds the application configuration.

func Load

func Load() (*Config, error)

Load reads the config file from disk.

func (*Config) Get

func (c *Config) Get(key string) (string, error)

Get returns a config value by key name.

func (*Config) Save

func (c *Config) Save() error

Save writes the config to disk.

func (*Config) Set

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

Set updates a config value by key name.

type HostConfig

type HostConfig struct {
	Token      string `json:"token"`
	User       string `json:"user,omitempty"`
	Protocol   string `json:"protocol,omitempty"`
	APIHost    string `json:"api_host,omitempty"`
	AuthMethod string `json:"auth_method,omitempty"` // "pat" or "oauth"
	ClientID   string `json:"client_id,omitempty"`
}

HostConfig stores per-host authentication and settings.

type HostsConfig

type HostsConfig map[string]*HostConfig

HostsConfig maps hostnames to their configurations.

func LoadHosts

func LoadHosts() (HostsConfig, error)

LoadHosts reads the hosts configuration from disk.

Jump to

Keyboard shortcuts

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