Documentation
¶
Index ¶
- Constants
- func LocalGitData(ctx context.Context, rt *toolkit.Runtime, projectPath, key string) ([]byte, error)
- type BacklinksOptions
- type CatOptions
- type Config
- func (cfg *Config) AddKeg(alias string, target kegurl.Target) error
- func (cfg *Config) AddKegMap(entry KegMapEntry) error
- func (cfg *Config) Clone() *Config
- func (cfg *Config) DefaultKeg() string
- func (cfg *Config) DefaultRegistry() string
- func (cfg *Config) KegMap() []KegMapEntry
- func (cfg *Config) Kegs() map[string]kegurl.Target
- func (cfg *Config) ListKegs() []string
- func (cfg *Config) LogFile() string
- func (cfg *Config) LogLevel() string
- func (cfg *Config) LookupAlias(rt *toolkit.Runtime, projectRoot string) string
- func (cfg *Config) Registries() []KegRegistry
- func (cfg *Config) ResolveAlias(alias string) (*kegurl.Target, error)
- func (cfg *Config) ResolveDefault(rt *toolkit.Runtime) (*kegurl.Target, error)
- func (cfg *Config) ResolveKegMap(rt *toolkit.Runtime, projectRoot string) (*kegurl.Target, error)
- func (cfg *Config) SetDefaultKeg(keg string) error
- func (cfg *Config) SetDefaultRegistry(_ context.Context, registry string) error
- func (cfg *Config) SetLogFile(_ context.Context, path string) error
- func (cfg *Config) SetLogLevel(level string) error
- func (cfg *Config) SetUserRepoPath(path string) error
- func (cfg *Config) ToYAML() ([]byte, error)
- func (cfg *Config) Touch(rt *toolkit.Runtime)
- func (cfg *Config) Updated() time.Time
- func (cfg *Config) UserRepoPath() string
- func (cfg *Config) Write(rt *toolkit.Runtime, path string) error
- type ConfigEditOptions
- type ConfigOptions
- type ConfigService
- func (s *ConfigService) Config(cache bool) *Config
- func (s *ConfigService) LocalRepoKegs(cache bool) ([]string, error)
- func (s *ConfigService) ProjectConfig(cache bool) (*Config, error)
- func (s *ConfigService) ResetCache()
- func (s *ConfigService) ResolveTarget(alias string, cache bool) (*kegurl.Target, error)
- func (s *ConfigService) UserConfig(cache bool) (*Config, error)
- type CreateOptions
- type DirOptions
- type EditOptions
- type GrepOptions
- type IndexOptions
- type InfoEditOptions
- type InfoOptions
- type InitOptions
- type KegInfoOptions
- type KegMapEntry
- type KegRegistry
- type KegService
- type KegTargetOptions
- type ListOptions
- type MetaOptions
- type MoveOptions
- type PathService
- type ProjectKegNotFoundError
- type RemoveOptions
- type ResolveKegOptions
- type StatsOptions
- type TagsOptions
- type Tap
- func (t *Tap) Backlinks(ctx context.Context, opts BacklinksOptions) ([]string, error)
- func (t *Tap) Cat(ctx context.Context, opts CatOptions) (string, error)
- func (t *Tap) Config(opts ConfigOptions) (string, error)
- func (t *Tap) ConfigEdit(ctx context.Context, opts ConfigEditOptions) error
- func (t *Tap) Create(ctx context.Context, opts CreateOptions) (keg.NodeId, error)
- func (t *Tap) Dir(ctx context.Context, opts DirOptions) (string, error)
- func (t *Tap) Edit(ctx context.Context, opts EditOptions) error
- func (t *Tap) Grep(ctx context.Context, opts GrepOptions) ([]string, error)
- func (t *Tap) Index(ctx context.Context, opts IndexOptions) (string, error)
- func (t *Tap) Info(ctx context.Context, opts InfoOptions) (string, error)
- func (t *Tap) InfoEdit(ctx context.Context, opts InfoEditOptions) error
- func (t *Tap) InitKeg(ctx context.Context, name string, options InitOptions) error
- func (t *Tap) KegInfo(ctx context.Context, opts KegInfoOptions) (string, error)
- func (t *Tap) List(ctx context.Context, opts ListOptions) ([]string, error)
- func (t *Tap) ListKegs(cache bool) ([]string, error)
- func (t *Tap) LookupKeg(ctx context.Context, kegAlias string) (*keg.Keg, error)
- func (t *Tap) Meta(ctx context.Context, opts MetaOptions) (string, error)
- func (t *Tap) Move(ctx context.Context, opts MoveOptions) error
- func (t *Tap) Remove(ctx context.Context, opts RemoveOptions) error
- func (t *Tap) Stats(ctx context.Context, opts StatsOptions) (string, error)
- func (t *Tap) Tags(ctx context.Context, opts TagsOptions) ([]string, error)
- type TapOptions
Constants ¶
const ( // DefaultAppName is the base directory name used for Tapper user // configuration. Helpers use this value to build platform specific config // paths, for example: // $XDG_CONFIG_HOME/tapper (or ~/.config/tapper) on Unix-like systems // %APPDATA%\tapper on Windows // Example config file: // $XDG_CONFIG_HOME/tapper/aliases.yaml DefaultAppName = "tapper" // DefaultLocalConfigDir is the directory name used for repository or // project local configuration. DefaultLocalConfigDir = ".tapper" )
Config version strings identify KEG configuration schema versions. Each constant is a stable identifier for a particular config schema. When a new schema is introduced add a new constant and update the Config alias to point to the latest version. These values are used by parsing and migration code (for example ParseConfigData) to detect older formats and perform upgrades. Use a YYYY-MM format for easy sorting and human readability.
Variables ¶
This section is empty.
Functions ¶
func LocalGitData ¶
func LocalGitData(ctx context.Context, rt *toolkit.Runtime, projectPath, key string) ([]byte, error)
LocalGitData attempts to run `git -C projectPath config --local --get key`.
If git is not present or the command fails it returns an error. The returned bytes are trimmed of surrounding whitespace. The function logs diagnostic messages using the logger from rt.
Types ¶
type BacklinksOptions ¶
type BacklinksOptions struct {
KegTargetOptions
// NodeID is the target node to inspect incoming links for.
NodeID string
// Format to use. %i is node id
// %d is date
// %t is node title
// %% for literal %
Format string
IdOnly bool
Reverse bool
}
type CatOptions ¶
type CatOptions struct {
// NodeIDs are the node identifiers to read (e.g., "0", "42").
// Multiple IDs produce concatenated output separated by blank lines.
NodeIDs []string
// Tag is an optional tag expression (same syntax as tap tags) used to
// select nodes. Mutually exclusive with NodeIDs.
Tag string
KegTargetOptions
// Edit opens the node in the editor instead of printing output.
Edit bool
// ContentOnly displays content only.
ContentOnly bool
// StatsOnly displays stats only.
StatsOnly bool
// MetaOnly displays metadata only.
MetaOnly bool
// Stream carries stdin piping information when editing.
Stream *toolkit.Stream
}
CatOptions configures behavior for Runner.Cat.
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config represents the user's tapper configuration.
Config is a data-only model. We do not preserve YAML comments or original document formatting.
func DefaultProjectConfig ¶
func DefaultUserConfig ¶
DefaultUserConfig returns a sensible default Config for a new user.
The returned Config is a fully populated in-memory config suitable as a starting point when no on-disk config is available. The DefaultRegistry is set to "knut" and a local file based keg pointing at the user data path is provided under the alias "local".
func MergeConfig ¶
MergeConfig merges multiple Config values into a single configuration.
Merge semantics:
- Later configs override earlier values for the same keys.
- KegMap entries are appended in order, but entries with the same Keg are overridden by later entries.
- The returned Config will have a Kegs map and a KegMap slice.
func ParseConfig ¶
ParseConfig parses raw YAML into a Config data model.
func ReadConfig ¶
ReadConfig reads the YAML file at path and returns a parsed Config.
When the file does not exist the function returns a Config value and an error that wraps keg.ErrNotExist so callers can detect no-config cases.
func (*Config) AddKegMap ¶
func (cfg *Config) AddKegMap(entry KegMapEntry) error
AddKegMap adds or updates a keg map entry in the Config.
func (*Config) DefaultKeg ¶
DefaultKeg returns the alias of the default keg to use.
func (*Config) DefaultRegistry ¶
DefaultRegistry returns the default registry name.
func (*Config) KegMap ¶
func (cfg *Config) KegMap() []KegMapEntry
KegMap returns the list of path/regex to keg alias mappings.
func (*Config) ListKegs ¶
ListKegs returns a sorted slice of all keg names in the configuration. Returns an empty slice if the config or its data is nil.
func (*Config) LookupAlias ¶
LookupAlias returns the keg alias matching the given project root path. It first checks regex patterns in KegMap entries, then prefix matches. For multiple prefix matches, the longest matching prefix wins. Returns empty string if no match is found or config data is nil.
func (*Config) Registries ¶
func (cfg *Config) Registries() []KegRegistry
Registries return the list of configured registries.
func (*Config) ResolveAlias ¶
ResolveAlias looks up the keg by alias and returns a parsed Target.
Returns (nil, error) when not found or parse fails.
func (*Config) ResolveDefault ¶
func (*Config) ResolveKegMap ¶
ResolveKegMap chooses the appropriate keg (via alias) based on path.
Precedence rules:
- Regex entries in KegMap have the highest precedence.
- PathPrefix entries are considered next; when multiple prefixes match the longest prefix wins.
- If no entry matches, the DefaultKeg is used if set.
The function expands env vars and tildes prior to comparisons, so stored prefixes and patterns may contain ~ or $VAR values.
func (*Config) SetDefaultKeg ¶
SetDefaultKeg sets the default keg alias.
func (*Config) SetDefaultRegistry ¶
SetDefaultRegistry sets the default registry.
func (*Config) SetLogFile ¶
SetLogFile sets the log file path.
func (*Config) SetLogLevel ¶
SetLogLevel sets the log level.
func (*Config) SetUserRepoPath ¶
SetUserRepoPath sets the user repository path.
func (*Config) UserRepoPath ¶
UserRepoPath returns the path to discover KEGs on the local file system.
type ConfigEditOptions ¶
type ConfigEditOptions struct {
// Project indicates whether to edit local config instead of user config
Project bool
User bool
ConfigPath string
}
ConfigEditOptions configures behavior for Tap.ConfigEdit.
type ConfigOptions ¶
type ConfigOptions struct {
// Project indicates whether to display project config
Project bool
// User indicates whether to display user config
User bool
// Template prints out a templated. Combine with either project or user
// flag. Defaults to using --user flag
Template bool
}
ConfigOptions configures behavior for Tap.Config.
type ConfigService ¶
type ConfigService struct {
Runtime *toolkit.Runtime
PathService *PathService
// ConfigPath is the path to the config file.
ConfigPath string
// contains filtered or unexported fields
}
func NewConfigService ¶
func NewConfigService(root string, rt *toolkit.Runtime) (*ConfigService, error)
func (*ConfigService) Config ¶
func (s *ConfigService) Config(cache bool) *Config
Config returns the merged user and project configuration with optional caching. If cache is true and a merged config exists, it returns the cached version. Otherwise, it retrieves both configs, merges them, caches the result, and returns it.
func (*ConfigService) LocalRepoKegs ¶
func (s *ConfigService) LocalRepoKegs(cache bool) ([]string, error)
func (*ConfigService) ProjectConfig ¶
func (s *ConfigService) ProjectConfig(cache bool) (*Config, error)
ProjectConfig returns the project-level configuration with optional caching. If cache is true and a cached config exists, it returns the cached version. Otherwise, it reads the config from the local config root and caches the result.
func (*ConfigService) ResetCache ¶
func (s *ConfigService) ResetCache()
func (*ConfigService) ResolveTarget ¶
func (*ConfigService) UserConfig ¶
func (s *ConfigService) UserConfig(cache bool) (*Config, error)
UserConfig returns the global user configuration
type CreateOptions ¶
type CreateOptions struct {
KegTargetOptions
Title string
Lead string
Tags []string
Attrs map[string]string
Stream *toolkit.Stream
}
CreateOptions configures behavior for Runner.Create.
type DirOptions ¶
type DirOptions struct {
KegTargetOptions
NodeID string
}
type EditOptions ¶
type EditOptions struct {
// NodeID is the node identifier to edit (e.g., "0", "42")
NodeID string
KegTargetOptions
// Stream carries stdin piping information.
Stream *toolkit.Stream
}
EditOptions configures behavior for Tap.Edit.
type GrepOptions ¶
type GrepOptions struct {
KegTargetOptions
// Query is the regex pattern used to search nodes.
Query string
// Format to use. %i is node id
// %d is date
// %t is node title
// %% for literal %
Format string
IdOnly bool
Reverse bool
// IgnoreCase enables case-insensitive regex matching.
IgnoreCase bool
}
type IndexOptions ¶
type IndexOptions struct {
KegTargetOptions
// Rebuild rebuilds the full index
Rebuild bool
// NoUpdate skips updating node meta information
NoUpdate bool
}
IndexOptions configures behavior for Runner.Index.
type InfoEditOptions ¶
type InfoEditOptions struct {
KegTargetOptions
Stream *toolkit.Stream
}
InfoEditOptions configures behavior for Tap.InfoEdit.
type InfoOptions ¶
type InfoOptions struct {
KegTargetOptions
}
InfoOptions configures behavior for Tap.Info.
type InitOptions ¶
type InitOptions struct {
// Destination selection. Exactly one may be true.
Project bool
User bool
Registry bool
// For project destination: when true, use cwd as the project root base.
// Otherwise git root is preferred (falling back to cwd).
Cwd bool
// Registry-specific options.
Repo string // registry name
UserName string // registry namespace
TokenEnv string
// Keg name (user destination)
Name string
// Explicit filesystem path for local destinations.
Path string
Creator string
Title string
Keg string
}
InitOptions configures behavior for Runner.InitKeg.
type KegInfoOptions ¶
type KegInfoOptions struct {
KegTargetOptions
}
KegInfoOptions configures behavior for Tap.KegInfo.
type KegMapEntry ¶
type KegMapEntry struct {
Alias string `yaml:"alias,omitempty"`
PathPrefix string `yaml:"pathPrefix,omitempty"`
PathRegex string `yaml:"pathRegex,omitempty"`
}
KegMapEntry is an entry mapping a path prefix or regex to a keg alias.
type KegRegistry ¶
type KegRegistry struct {
Name string `yaml:"name,omitempty"`
Url string `yaml:"url,omitempty"`
Token string `yaml:"token,omitempty"`
TokenEnv string `yaml:"tokenEnv,omitempty"`
}
KegRegistry describes a named registry configuration entry.
type KegService ¶
type KegService struct {
Runtime *toolkit.Runtime
ConfigService *ConfigService
// contains filtered or unexported fields
}
func (*KegService) Resolve ¶
func (s *KegService) Resolve(ctx context.Context, opts ResolveKegOptions) (*keg.Keg, error)
type KegTargetOptions ¶
type KegTargetOptions struct {
// Keg is the configured alias.
Keg string
// Project resolves using project-local keg discovery.
Project bool
// Cwd, when combined with Project, uses cwd as the base instead of git root.
Cwd bool
// Path is an explicit local project path used for project keg discovery.
Path string
}
KegTargetOptions describes how a command should resolve a keg target.
type ListOptions ¶
type ListOptions struct {
KegTargetOptions
// Format to use. %i is node id, %d
// %i is node id
// %d is date
// %t is node title
// %% for literal %
Format string
IdOnly bool
Reverse bool
}
type MetaOptions ¶
type MetaOptions struct {
// NodeID is the node identifier to inspect (e.g., "0", "42")
NodeID string
KegTargetOptions
// Edit opens metadata in the editor.
Edit bool
// Stream carries stdin piping information.
Stream *toolkit.Stream
}
MetaOptions configures behavior for Tap.Meta.
type MoveOptions ¶
type MoveOptions struct {
KegTargetOptions
SourceID string
DestID string
}
type PathService ¶
func NewPathService ¶
func NewPathService(rt *toolkit.Runtime, root string) (*PathService, error)
func (*PathService) Project ¶
func (s *PathService) Project() string
func (*PathService) ProjectConfig ¶
func (s *PathService) ProjectConfig() string
func (*PathService) UserConfig ¶
func (s *PathService) UserConfig() string
type ProjectKegNotFoundError ¶
type ProjectKegNotFoundError struct {
Tried []string
}
ProjectKegNotFoundError indicates project-local keg discovery failed. Tried contains the concrete keg-file locations that were checked.
func (*ProjectKegNotFoundError) Error ¶
func (e *ProjectKegNotFoundError) Error() string
type RemoveOptions ¶
type RemoveOptions struct {
KegTargetOptions
NodeIDs []string
}
type ResolveKegOptions ¶
type StatsOptions ¶
type StatsOptions struct {
// NodeID is the node identifier to inspect (e.g., "0", "42")
NodeID string
KegTargetOptions
}
StatsOptions configures behavior for Tap.Stats.
type TagsOptions ¶
type TagsOptions struct {
KegTargetOptions
// Tag filters nodes by tag. When empty, all tags are listed.
Tag string
// Format to use. %i is node id
// %d is date
// %t is node title
// %% for literal %
Format string
IdOnly bool
Reverse bool
}
type Tap ¶
type Tap struct {
Root string
// Runtime carries process-level dependencies.
Runtime *toolkit.Runtime
PathService *PathService
ConfigService *ConfigService
KegService *KegService
}
func NewTap ¶
func NewTap(opts TapOptions) (*Tap, error)
func (*Tap) Cat ¶
Cat reads and displays node(s) content with metadata as frontmatter.
When multiple node IDs are provided, outputs are concatenated and separated by blank lines. When --tag is provided, nodes are selected by tag expression.
func (*Tap) Config ¶
func (t *Tap) Config(opts ConfigOptions) (string, error)
Config displays the merged or project configuration.
func (*Tap) ConfigEdit ¶
func (t *Tap) ConfigEdit(ctx context.Context, opts ConfigEditOptions) error
ConfigEdit opens the configuration file in the default editor.
func (*Tap) Create ¶
Create creates a new node in the project's default keg.
It resolves the TapProject (via r.getProject), determines the project's default keg target, constructs a Keg service for that target, and delegates to keg.Keg.Create to allocate and persist the new node.
Errors are wrapped with contextual messages to aid callers.
func (*Tap) Edit ¶
func (t *Tap) Edit(ctx context.Context, opts EditOptions) error
Edit opens a node in an editor using a temporary markdown file.
The temp file format is:
--- <meta yaml> --- <markdown body>
If stdin is piped, it seeds the temp file content. On save, frontmatter is written to meta.yaml and the body is written to the node content file.
func (*Tap) Index ¶
Index updates indices for a keg (nodes.tsv, tags, links, backlinks). Default behavior is incremental. Set opts.Rebuild to force a full rebuild.
func (*Tap) InfoEdit ¶
func (t *Tap) InfoEdit(ctx context.Context, opts InfoEditOptions) error
InfoEdit opens the keg configuration file in the default editor.
func (*Tap) InitKeg ¶
InitKeg creates a keg entry for the given name.
If the name is empty, an ErrInvalid-wrapped error is returned. InitKeg gets the project via getProject and then performs the actions required to create a keg. The current implementation defers to project.DefaultKeg for further resolution and returns any error encountered when obtaining the project.
func (*Tap) ListKegs ¶
ListKegs returns all available keg directories by scanning the user repository and merging with configured keg aliases. When cache is true, cached config values may be used.