Documentation
¶
Overview ¶
Package configpath resolves a single config file path for configbind. Explicit --config-path wins; otherwise configdir user then system is searched exclusively.
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 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.
If explicitPath is empty, 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 layer may be skipped).
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).