config

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 6 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 (
	EnvTokenKey    = "GITHUB_TOKEN"
	ConfigFileName = "go-gists.ini"

	// Defaults
	DefaultMinTableWidth = 100 // narrower → compact list mode
	DefaultDescRatio     = 55  // 55% description, 45% URL
)

Variables

This section is empty.

Functions

func ConfigFilePath

func ConfigFilePath() (string, error)

ConfigFilePath returns the resolved config file path.

func Save

func Save(token string) error

Save persists the token (and current display defaults if the file is new) to the config file without overwriting existing display settings.

func SaveDisplay added in v1.0.1

func SaveDisplay(d DisplayConfig) error

SaveDisplay writes only the display settings to the config file.

Types

type Config

type Config struct {
	Token   string
	Display DisplayConfig
}

Config holds the full application configuration.

func Load

func Load() (*Config, error)

Load resolves config with the following priority:

  1. GITHUB_TOKEN env var (token only)
  2. Config file (~/.config/go-gists/go-gists.ini)

Display settings always come from the config file (with built-in defaults when the file or specific keys are absent).

type DisplayConfig added in v1.0.1

type DisplayConfig struct {
	// MinTableWidth is the terminal width (columns) below which compact list
	// mode is used instead of the full 4-column table.
	MinTableWidth int

	// DescRatio is the percentage of the flexible width (after # and ID columns
	// are accounted for) that is allocated to the Description column.
	// The remaining percentage goes to URL. Range: 1–99.
	DescRatio int
}

DisplayConfig controls how the list output is rendered.

type ErrTokenNotFound

type ErrTokenNotFound struct{ Path string }

ErrTokenNotFound is returned when no token can be resolved.

func (ErrTokenNotFound) Error

func (e ErrTokenNotFound) Error() string

Jump to

Keyboard shortcuts

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