Documentation
¶
Overview ¶
Package shared holds domain logic used by multiple alias subcommands: alias name and expansion validation, and the shipped-default lookup.
Index ¶
- func AliasFieldPath(name string) string
- func DefaultAliases() (map[string]string, error)
- func ExportTarget(cfg config.Config) (string, error)
- func LayersContaining(cfg config.Config, name string) []string
- func OpenFileStore(target string) (*storage.Store[config.Project], error)
- func SamePath(a, b string) bool
- func SetTarget() (string, error)
- func SplitExpansion(expansion string) ([]string, error)
- func ValidateExpansionTarget(name, expansion string, validCommand ValidCommandFunc, ...) error
- func ValidateName(name string) error
- func WriteAliases(out io.Writer, path string, mutate func(map[string]string)) error
- type ValidCommandFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AliasFieldPath ¶
AliasFieldPath returns the dotted store path for one alias entry, e.g. "aliases.go" — the key used in provenance and layer lookups.
func DefaultAliases ¶
DefaultAliases returns the shipped default alias map (the defaults layer of the project config, independent of any files on disk).
func ExportTarget ¶
ExportTarget resolves the project config file that alias export writes to: the most local, highest-priority discovered project layer in the walk-up. Export never creates files — only already-discovered layers qualify — and the user-level project config in the clawker config directory is not a walk-up layer.
func LayersContaining ¶
LayersContaining returns the absolute paths of every discovered file layer whose raw data carries an entry for the alias, ordered highest priority first. Defaults (virtual) layers are excluded.
func OpenFileStore ¶
OpenFileStore opens an isolated store on a single project config file — no defaults layer, no walk-up, no user-level merging. This scopes a write to exactly the alias entries: the composite project store marks every defaults-provenance field dirty at construction (how init/bootstrap materializes defaults), so a write through it would also backfill any schema fields the file doesn't carry — fine for init, surprising as a side effect of an alias command.
func SetTarget ¶
SetTarget resolves the file that alias set writes to: the user-level project config in the clawker config directory (the base config file layer). The file is created on first write if missing.
func SplitExpansion ¶
SplitExpansion validates an alias expansion and returns its argv tokens.
func ValidateExpansionTarget ¶
func ValidateExpansionTarget(name, expansion string, validCommand ValidCommandFunc, aliases map[string]string) error
ValidateExpansionTarget checks that an expansion's first token resolves to something executable: a real clawker command or another configured alias. name is the alias being defined — a direct self-reference is rejected.
func ValidateName ¶
ValidateName checks that an alias name is usable as a single command token.
Types ¶
type ValidCommandFunc ¶
ValidCommandFunc reports whether name belongs to a real (non-alias) clawker command or one of its cobra aliases. The root command provides the implementation once the full command tree is built.