config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HostMirror = "mirror"
	HostMain   = "main"
)

Host names accepted by --host / config.

View Source
const AppDirName = ".javdb-cli"

AppDirName is the directory under the user home used for credentials/config.

Variables

View Source
var HostURLs = map[string]string{
	HostMirror: "https://jdforrepam.com",
	HostMain:   "https://javdb.com",
}

HostURLs maps logical host names to base URLs.

Functions

func AuthPath

func AuthPath() (string, error)

func ConfigPath

func ConfigPath() (string, error)

func DeviceUUIDPath

func DeviceUUIDPath() (string, error)

func Dir

func Dir() (string, error)

Dir returns ~/.javdb-cli (or $HOME/.javdb-cli), creating nothing.

func EnsureDir

func EnsureDir() (string, error)

EnsureDir creates the config directory with 0700 permissions.

func SaveFile

func SaveFile(path string, s Settings) error

SaveFile writes settings sparsely to path (0600).

func TagTaxonomyPath

func TagTaxonomyPath(zone string) (string, error)

func ValidateHost

func ValidateHost(host string) error

ValidateHost returns error if host is not a known name or absolute URL.

Types

type Runtime

type Runtime struct {
	Host        string // mirror | main
	BaseURL     string
	Proxy       string
	AutoRelogin bool
	Lang        string
	DeviceUUID  string
}

Runtime is the resolved config after flag > env > file > default.

func Resolve

func Resolve(file Settings, flagHost, flagProxy string, flagAutoRelogin *bool) Runtime

Resolve merges flag/env/file/defaults. flagHost / flagProxy empty means "not set". flagAutoRelogin: nil = not set; non-nil overrides.

type Settings

type Settings struct {
	Host        string `toml:"host"`
	HTTPSProxy  string `toml:"https_proxy,omitempty"`
	AutoRelogin bool   `toml:"auto_relogin"`
	Lang        string `toml:"lang,omitempty"`
	DeviceUUID  string `toml:"device_uuid,omitempty"` // optional override; else file/device_uuid
}

Settings is the on-disk config.toml schema.

func Defaults

func Defaults() Settings

Defaults returns baseline settings.

func LoadFile

func LoadFile(path string) (Settings, error)

LoadFile reads config.toml; missing file returns Defaults().

Jump to

Keyboard shortcuts

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