configpath

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

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

View Source
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

func ConfigPathDef() cliparser.Def

ConfigPathDef returns the process-level cliparser definition for --config-path. ConfigKey is ProcessKey ("config-path"), not a Bind-prefix field key.

func ExplicitPathFromParse

func ExplicitPathFromParse(res cliparser.Result) string

ExplicitPathFromParse extracts the --config-path value from a cliparser.Result, if set.

func Resolve

func Resolve(vendor, tool, fileName, explicitPath string) (path string, found bool, err error)

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).

func (ConfigDirSearch) Find

func (ConfigDirSearch) Find(vendor, tool, fileName string) (string, bool)

Find implements FileSearch using configdir.QueryFolderContainsFile.

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

type FixedRootsSearch struct {
	UserRoot   string
	SystemRoot string
}

FixedRootsSearch searches userRoot then systemRoot with vendor/tool segments (for tests).

func (FixedRootsSearch) Find

func (s FixedRootsSearch) Find(vendor, tool, fileName string) (string, bool)

Find implements FileSearch with explicit roots, user preferred over system.

Jump to

Keyboard shortcuts

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