shared

package
v0.12.9 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package shared holds domain logic used by multiple alias subcommands: alias name and expansion validation, and the shipped-default lookup.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AliasFieldPath

func AliasFieldPath(name string) string

AliasFieldPath returns the dotted store path for one alias entry, e.g. "aliases.go" — the key used in provenance and layer lookups.

func DefaultAliases

func DefaultAliases() (map[string]string, error)

DefaultAliases returns the shipped default alias map (the defaults layer of the project config, independent of any files on disk).

func ExportTarget

func ExportTarget(cfg config.Config) (string, error)

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

func LayersContaining(cfg config.Config, name string) []string

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

func OpenFileStore(target string) (*storage.Store[config.Project], error)

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 SamePath

func SamePath(a, b string) bool

SamePath reports whether a and b denote the same file after cleaning.

func SetTarget

func SetTarget() (string, error)

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

func SplitExpansion(expansion string) ([]string, error)

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

func ValidateName(name string) error

ValidateName checks that an alias name is usable as a single command token.

func WriteAliases

func WriteAliases(out io.Writer, path string, mutate func(map[string]string)) error

WriteAliases applies mutate to the isolated store on path (see OpenFileStore), persists it, and reports the write on out. mutate receives a non-nil aliases map.

Types

type ValidCommandFunc

type ValidCommandFunc func(name string) bool

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.

Jump to

Keyboard shortcuts

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