Documentation
¶
Overview ¶
Package configpath resolves one config file path for configbind. Candidates are searched exclusively in priority order: explicit path, extra read paths, user config, then system config.
Index ¶
- Constants
- func ConfigPathDef() cliparser.Def
- func ExplicitPathFromParse(res cliparser.Result) string
- func Resolve(vendor, tool, fileName, explicitPath string) (path string, found bool, err error)
- func ResolveWithExtras(vendor, tool, fileName, explicitPath string, extraReadPaths []string) (path string, found bool, err error)
- func ResolveWithExtrasAndSearch(vendor, tool, fileName, explicitPath string, extraReadPaths []string, ...) (path string, found bool, err error)
- func ResolveWithSearch(vendor, tool, fileName, explicitPath string, search FileSearch) (path string, found bool, err error)
- type ConfigDirSearch
- type FileSearch
- type FixedRootsSearch
Constants ¶
const ProcessKey = "config-path"
ProcessKey is the stable process-level key for the --config-path value in cliparser results. It is not a Bind-prefix overlay key.
Variables ¶
This section is empty.
Functions ¶
func ConfigPathDef ¶
ConfigPathDef returns the process-level cliparser definition for --config-path. ConfigKey is ProcessKey ("config-path"), not a Bind-prefix field key.
func ExplicitPathFromParse ¶
ExplicitPathFromParse extracts the --config-path value from a cliparser.Result, if set.
func Resolve ¶
Resolve chooses one config file path.
If explicitPath is non-empty, that path is the only candidate: missing or unreadable returns an error (no directory search fallback). On success found is true.
With no explicit path or extras, vendor, tool, and fileName are required; directory search prefers user over system and returns at most one path. When neither has the file, found is false and err is nil (TOML may be skipped).
func ResolveWithExtras ¶ added in v0.1.12
func ResolveWithExtras(vendor, tool, fileName, explicitPath string, extraReadPaths []string) (path string, found bool, err error)
ResolveWithExtras chooses the first readable config file from explicitPath, extraReadPaths in slice order, then the user/system config directory search. Missing or unreadable extra paths are skipped. An explicit path remains strict: when supplied but unreadable, resolution fails without fallback.
func ResolveWithExtrasAndSearch ¶ added in v0.1.12
func ResolveWithExtrasAndSearch(vendor, tool, fileName, explicitPath string, extraReadPaths []string, search FileSearch) (path string, found bool, err error)
ResolveWithExtrasAndSearch is like ResolveWithExtras but injects the user/system directory search implementation.
func ResolveWithSearch ¶
func ResolveWithSearch(vendor, tool, fileName, explicitPath string, search FileSearch) (path string, found bool, err error)
ResolveWithSearch is like Resolve but uses the provided FileSearch for directory lookup.
Types ¶
type ConfigDirSearch ¶
type ConfigDirSearch struct{}
ConfigDirSearch uses github.com/shibukawa/configdir (user then system, exclusive).
type FileSearch ¶
type FileSearch interface {
// Find returns the full path to fileName if present under vendor/tool layout.
Find(vendor, tool, fileName string) (fullPath string, found bool)
}
FileSearch finds a config file under vendor/tool directories (user first, then system). Production uses ConfigDirSearch; tests may inject fixed roots.
type FixedRootsSearch ¶
FixedRootsSearch searches userRoot then systemRoot with vendor/tool segments (for tests).