Documentation
¶
Index ¶
- Constants
- Variables
- func CLISettingAliases() []string
- func ClearFanboxDefaultUserID() error
- func ClearPixivDefaultUserID() error
- func EnsureDefaultConfigFile() error
- func EnvValue(spec SettingSpec) (string, bool)
- func IsSensitiveSetting(alias string) bool
- func PublicSettingText(alias, text string) string
- func ReadFanboxDefaultUserID() (userID int64, ok bool, err error)
- func ReadPixivDefaultUserID() (userID int64, ok bool, err error)
- func RemovedSettingError(alias string) error
- func SetConfigValue(path, alias string, value parser.Value) error
- func SetConfigValueWithFileStore(path, alias string, value parser.Value, store FileStore) error
- func SetFanboxDefaultUserID(userID int64) error
- func SetPixivDefaultUserID(userID int64) error
- func UnsetConfigValue(path, alias string) (bool, error)
- func UnsetConfigValueWithFileStore(path, alias string, store FileStore) (bool, error)
- func ValidSettingAliases() []string
- type AccountPoolConfig
- type AccountPoolStrategy
- type ConfigMutationResult
- type FileStore
- type FlareSolverrConfig
- type OptionalString
- type RuntimeConfig
- type ServiceNetworkConfig
- type SettingSpec
- type SettingValue
- type Snapshot
- type Store
- func (s Store) ClearFanboxDefaultUserID() error
- func (s Store) ClearPixivDefaultUserID() error
- func (s Store) Current() (Snapshot, error)
- func (s Store) EnsureDefaultConfigFile() error
- func (s Store) Get(alias string) (SettingValue, error)
- func (s Store) Path() (string, error)
- func (s Store) ReadFanboxDefaultUserID() (userID int64, ok bool, err error)
- func (s Store) ReadPixivDefaultUserID() (userID int64, ok bool, err error)
- func (s Store) Set(alias, raw string) (ConfigMutationResult, error)
- func (s Store) SetFanboxDefaultUserID(userID int64) error
- func (s Store) SetPixivDefaultUserID(userID int64) error
- func (s Store) Unset(alias string) (ConfigMutationResult, error)
Constants ¶
const ( DefaultDownloadPath = "./downloads" DefaultFilenameTemplate = "{author} - {title}_{id}" )
Variables ¶
var ErrRemovedSetting = errors.New("removed_setting")
ErrRemovedSetting 表示该配置键已随版本删除。旧配置仍显式包含它时返回;用户 通过 `pixiv config unset` 清理后不再出现。
Functions ¶
func CLISettingAliases ¶
func CLISettingAliases() []string
CLISettingAliases 返回由 pixiv config 命令管理的非移除配置键。
func ClearFanboxDefaultUserID ¶
func ClearFanboxDefaultUserID() error
ClearFanboxDefaultUserID 删除 [fanbox.auth].default_user_id,恢复首个入库账号。
func ClearPixivDefaultUserID ¶
func ClearPixivDefaultUserID() error
ClearPixivDefaultUserID 删除 [pixiv.auth].default_user_id,恢复首个入库账号。
func EnsureDefaultConfigFile ¶
func EnsureDefaultConfigFile() error
EnsureDefaultConfigFile 在配置首次缺失时生成由 schema 元数据驱动的精简基线文件。 高级设置仍需由用户显式写入,已有文件绝不覆盖。
func EnvValue ¶
func EnvValue(spec SettingSpec) (string, bool)
func IsSensitiveSetting ¶
IsSensitiveSetting 标记禁止通过公开配置查询回显的凭据型值。
func PublicSettingText ¶
PublicSettingText 返回可安全进入 CLI、SDK JSON 与日志边界的配置值。
func ReadFanboxDefaultUserID ¶
ReadFanboxDefaultUserID 返回 [fanbox.auth].default_user_id;未设置时 ok=false。
func ReadPixivDefaultUserID ¶
ReadPixivDefaultUserID 返回 [pixiv.auth].default_user_id;未设置时 ok=false。
func RemovedSettingError ¶
RemovedSettingError 构造一个同时能被 errors.Is 匹配 ErrRemovedSetting 的错误, 明确指导用户如何清理旧配置。已移除键在显式写入配置时对 runtime 生效,不设置 默认值,也不进入可写别名集合。
func SetConfigValueWithFileStore ¶
SetConfigValueWithFileStore 在注入的文件端口上执行稀疏配置写回。
func SetFanboxDefaultUserID ¶
SetFanboxDefaultUserID 写入 [fanbox.auth].default_user_id。
func SetPixivDefaultUserID ¶
SetPixivDefaultUserID 写入 [pixiv.auth].default_user_id。
func UnsetConfigValue ¶
func UnsetConfigValueWithFileStore ¶
UnsetConfigValueWithFileStore 在注入的文件端口上删除一个配置键。
func ValidSettingAliases ¶
func ValidSettingAliases() []string
Types ¶
type AccountPoolConfig ¶
type AccountPoolConfig struct {
Enabled bool
Strategy AccountPoolStrategy
}
AccountPoolConfig 描述内容读取和作品下载是否启用数据库账号调度及其策略。 UID、冻结时间和 marker 不进入 config.toml。
type AccountPoolStrategy ¶
type AccountPoolStrategy string
const ( AccountPoolStrategyRoundRobin AccountPoolStrategy = "round_robin" AccountPoolStrategyRandom AccountPoolStrategy = "random" )
type ConfigMutationResult ¶
type FileStore ¶
type FileStore interface {
Path() (string, error)
ReadFile(string) ([]byte, error)
WritePrivateFile(string, []byte) error
EnsurePrivateFile(string, []byte) error
}
FileStore 是 config/settings 所需的最小文件端口。生产实现由 composition root 注入;配置 schema 不直接依赖具体文件系统实现。
type FlareSolverrConfig ¶
type FlareSolverrConfig struct {
URL string `json:"url"`
ProxyURL string `json:"proxy_url,omitempty"`
}
FlareSolverrConfig describes the optional external challenge-recovery service. It is nil when the whole table is absent, which keeps the default runtime free of any solver dependency.
type OptionalString ¶
OptionalString preserves the difference between an absent advanced TOML key and an explicitly configured empty string. That distinction is required for service-scoped proxy routing: an empty service value means direct access instead of inheriting the global fallback.
type RuntimeConfig ¶
type RuntimeConfig struct {
DownloadPath string
FilenameTemplate string
DirectoryTemplate string
HTTPSProxy string
LogLevel string
LogFormat string
PixivNetwork ServiceNetworkConfig
FanboxNetwork ServiceNetworkConfig
ReverseSearchNetwork ServiceNetworkConfig
FanboxFlareSolverr *FlareSolverrConfig
ReverseSearchFlareSolverr *FlareSolverrConfig
RequestInterval time.Duration
UpdateCheckEnabled bool
OutputJSON bool
LoginOpenBrowser bool
LoginUseAfterLogin bool
ReverseSearchProvider string
ReverseSearchPixivOnly bool
SauceNAOAPIKey string
// LoginRelay* 描述本次运行时创建的跨机器浏览器中继。历史 secret/target
// 配置项仍可留在私有配置文件中,但不会载入 runtime,避免恢复旧 client relay。
LoginRelayPublicURL string
LoginRelayListenAddr string
LoginRelayTLSCertFile string
LoginRelayTLSKeyFile string
// AccountPool 只能在 config.toml 的 [account_pool] 表中手工维护,避免普通
// config set 的扁平字符串接口误写账号白名单。
AccountPool AccountPoolConfig
}
type ServiceNetworkConfig ¶
type ServiceNetworkConfig struct {
ProxyURL OptionalString `json:"proxy_url"`
UserAgent OptionalString `json:"user_agent"`
}
ServiceNetworkConfig contains only service-local network settings. These values are not aliases and are intentionally absent from the generated baseline config until a user writes the advanced TOML table.
type SettingSpec ¶
type SettingSpec struct {
Alias string
KoanfKey string
Table []string
Key string
Kind settingKind
// Sensitive 表示该值可用于认证或中继授权。它可以被写入私有 config.toml,
// 但绝不能通过 config get、日志或错误消息回显。
Sensitive bool
HasDefault bool
Default any
// DefaultInFile 表示该默认值是否进入首次生成的精简 config.toml。
DefaultInFile bool
// CLIManaged 表示该键是否由 pixiv config get/set/unset 暴露。
CLIManaged bool
// Removed 表示该键已随版本删除,只保留迁移墓碑。旧配置仍显式包含它时返回
// removed_setting;pixiv config unset 允许用户清理。墓碑不得驱动运行时分支。
Removed bool
}
func SettingSpecByAlias ¶
func SettingSpecByAlias(alias string) (SettingSpec, bool)
SettingSpecByAlias 返回 alias 对应的 spec。已移除键仍可被查询,以便 config unset 执行清理、config get/set 返回 removed_setting。
type SettingValue ¶
func ParseSettingInput ¶
func ParseSettingInput(alias, raw string) (SettingValue, parser.Value, error)
type Snapshot ¶
type Snapshot struct {
// contains filtered or unexported fields
}
func LoadSnapshot ¶
func LoadSnapshotAt ¶
LoadSnapshotAt 从明确给定的路径加载配置。SDK 需要它避免改动 包级测试路径或依赖调用进程的隐式当前配置位置。
func LoadSnapshotAtWithFileStore ¶
LoadSnapshotAtWithFileStore 从明确路径和注入的文件端口加载配置。它 让 composition root 可以把 platform/file mechanism 适配传入 schema owner。
func (Snapshot) Runtime ¶
func (s Snapshot) Runtime() (RuntimeConfig, error)
type Store ¶
type Store struct {
Files FileStore
}
Store 是配置 schema、文件 precedence 与稀疏写回的唯一 authority。 Files 只提供协议无关的路径/文件机制;Store 不缓存读取结果。
func DefaultStore ¶
func DefaultStore() Store
DefaultStore 返回使用 config/paths 默认路径与私密文件机制的配置 store。 需要注入文件端口的测试或 CLI composition root 应直接构造 Store{Files: ...}。
func (Store) ClearFanboxDefaultUserID ¶
func (Store) ClearPixivDefaultUserID ¶
func (Store) Current ¶
Current 每次从当前文件与环境生成新的 Snapshot。调用方应在一次 command/tool execution 开始时获取一次,并把该不可变快照传给后续依赖,避免运行中途配置撕裂。
func (Store) EnsureDefaultConfigFile ¶
EnsureDefaultConfigFile 在首次缺失时创建基线配置,且使用注入端口提供的 私密文件语义;已有文件不会被覆盖。
func (Store) ReadFanboxDefaultUserID ¶
func (Store) ReadPixivDefaultUserID ¶
ReadPixivDefaultUserID 从注入的配置文件端口读取默认账号 UID。
func (Store) SetFanboxDefaultUserID ¶
func (Store) SetPixivDefaultUserID ¶
SetPixivDefaultUserID 写入注入的配置文件端口。