config

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JudgmentModeOff    = "off"
	JudgmentModeShadow = "shadow"
	JudgmentModeAssist = "assist"
)

JudgmentModeOff 与 inboxjudgment 包的 off/shadow/assist 模式字面量一致; config 包不依赖实现包,字面量在此按合同钉住。

Variables

This section is empty.

Functions

func ErrorCode

func ErrorCode(err error) string

func JudgmentEffectiveMode added in v0.3.0

func JudgmentEffectiveMode(mode string) string

JudgmentEffectiveMode 归一化显示/装配用的 judgment mode:空值按 off。

func SetValue

func SetValue(path, key, value string) error

func UnsetValue

func UnsetValue(path, key string) error

func Value

func Value(cfg Config, key string) (string, bool)

Types

type Config

type Config struct {
	Vault    string         `mapstructure:"vault" yaml:"vault" json:"vault,omitempty"`
	Identity string         `mapstructure:"identity" yaml:"identity" json:"identity,omitempty"`
	Remote   RemoteConfig   `mapstructure:"remote" yaml:"remote" json:"remote"`
	Output   OutputConfig   `mapstructure:"output" yaml:"output" json:"output"`
	Editor   EditorConfig   `mapstructure:"editor" yaml:"editor" json:"editor"`
	Note     NoteConfig     `mapstructure:"note" yaml:"note" json:"note"`
	Search   SearchConfig   `mapstructure:"search" yaml:"search" json:"search"`
	Storage  StorageConfig  `mapstructure:"storage" yaml:"storage" json:"storage"`
	Themes   ThemeSet       `mapstructure:"themes" yaml:"themes" json:"themes"`
	Markdown MarkdownConfig `mapstructure:"markdown" yaml:"markdown" json:"markdown"`
	Judgment JudgmentConfig `mapstructure:"judgment" yaml:"judgment" json:"judgment"`
}

func DefaultConfig

func DefaultConfig() Config

func (Config) Validate

func (cfg Config) Validate() error

type EditorConfig

type EditorConfig struct {
	Command string `mapstructure:"command" yaml:"command" json:"command,omitempty"`
}

type Error

type Error struct {
	Code    string
	Message string
	Err     error
}

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type JudgmentConfig added in v0.3.0

type JudgmentConfig struct {
	Enabled bool   `mapstructure:"enabled" yaml:"enabled" json:"enabled"`
	Mode    string `mapstructure:"mode" yaml:"mode" json:"mode"`
}

JudgmentConfig 是实验性(experimental)inbox judgment 开关面。默认零值 即完全休眠:enabled=false 且 mode=off,inbox 流程零 judgment 装配、零 transport 调用。mode=shadow/assist 必须显式 enabled=true,非法组合在 配置加载时 fail-fast 拒绝。启用模式所需的 transport、精确模型 pin 与 授权注入不来自配置文件:本节只保存开关,不保存、不发现凭据或 adapter。

type LoadOptions

type LoadOptions struct {
	VaultPath         string
	UserConfigPath    string
	ProjectConfigPath string
	ExplicitFlags     map[string]string
	Env               func(string) (string, bool)
}

type LoadResult

type LoadResult struct {
	Config   Config              `json:"config"`
	Sources  SourceSet           `json:"sources"`
	Settings []SettingProjection `json:"settings,omitempty"`
}

func Load

func Load(opts LoadOptions) (LoadResult, error)

type MarkdownConfig

type MarkdownConfig struct {
	Enabled bool   `mapstructure:"enabled" yaml:"enabled" json:"enabled"`
	Style   string `mapstructure:"style" yaml:"style" json:"style"`
	Pager   string `mapstructure:"pager" yaml:"pager" json:"pager,omitempty"`
}

type NoteConfig

type NoteConfig struct {
	Status string `mapstructure:"status" yaml:"status" json:"status,omitempty"`
	Kind   string `mapstructure:"kind" yaml:"kind" json:"kind,omitempty"`
}

type OutputConfig

type OutputConfig struct {
	Style    string         `mapstructure:"style" yaml:"style" json:"style"`
	Color    string         `mapstructure:"color" yaml:"color" json:"color"`
	Theme    string         `mapstructure:"theme" yaml:"theme" json:"theme"`
	Width    int            `mapstructure:"width" yaml:"width" json:"width"`
	Markdown MarkdownConfig `mapstructure:"markdown" yaml:"markdown" json:"markdown"`
}

type PathOptions

type PathOptions struct {
	HomeDir       string
	XDGConfigHome string
	VaultPath     string
}

type Paths

type Paths struct {
	User    string `json:"user"`
	Project string `json:"project"`
}

func ResolvePaths

func ResolvePaths(opts PathOptions) Paths

type RemoteConfig

type RemoteConfig struct {
	APIURL string `mapstructure:"api_url" yaml:"api_url" json:"api_url,omitempty"`
	Mode   string `mapstructure:"mode" yaml:"mode" json:"mode,omitempty"`
}

type SearchConfig

type SearchConfig struct {
	Limit      int  `mapstructure:"limit" yaml:"limit" json:"limit"`
	AllowStale bool `mapstructure:"allow_stale" yaml:"allow_stale" json:"allow_stale"`
}

type SettingProjection added in v0.1.3

type SettingProjection struct {
	Key               string   `json:"key"`
	Value             string   `json:"value"`
	Source            string   `json:"source"`
	Writable          bool     `json:"writable"`
	WriteScope        string   `json:"write_scope"`
	WritableScopes    []string `json:"writable_scopes,omitempty"`
	NextAction        string   `json:"next_action,omitempty"`
	SecretRefBoundary string   `json:"secret_ref_boundary,omitempty"`
}

type SourceSet

type SourceSet struct {
	UserConfig    string   `json:"user_config,omitempty"`
	ProjectConfig string   `json:"project_config,omitempty"`
	EnvKeys       []string `json:"env_keys,omitempty"`
	FlagKeys      []string `json:"flag_keys,omitempty"`
}

func (SourceSet) Contains

func (s SourceSet) Contains(value string) bool

type StorageConfig

type StorageConfig struct {
	Backend  string `mapstructure:"backend" yaml:"backend" json:"backend,omitempty"`
	Bucket   string `mapstructure:"bucket" yaml:"bucket" json:"bucket,omitempty"`
	Region   string `mapstructure:"region" yaml:"region" json:"region,omitempty"`
	Prefix   string `mapstructure:"prefix" yaml:"prefix" json:"prefix,omitempty"`
	Endpoint string `mapstructure:"endpoint" yaml:"endpoint" json:"endpoint,omitempty"`
	Profile  string `mapstructure:"profile" yaml:"profile" json:"profile,omitempty"`
	Token    string `mapstructure:"token" yaml:"token" json:"-"`
}

type ThemeSet

type ThemeSet struct {
	Custom map[string]string `mapstructure:"custom" yaml:"custom" json:"custom,omitempty"`
}

Jump to

Keyboard shortcuts

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