config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package config loads dfetch's data source configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath() (string, error)

DefaultPath returns the home-directory fallback config path (~/dfetch.yaml).

Types

type Config

type Config struct {
	Sources []SourceConfig `yaml:"sources"`
	Queries []SavedQuery   `yaml:"queries"`
}

Config is the top-level dfetch configuration.

func Load

func Load(path string) (*Config, error)

Load reads the config from path. If path is empty, the default path is used (./dfetch.yaml if present, else ~/dfetch.yaml). A missing default config yields an empty Config rather than an error, so dfetch can run without a config file present.

func (*Config) Query

func (c *Config) Query(name string) (*SavedQuery, bool)

Query returns the saved query with the given name, if one is configured.

type SavedQuery

type SavedQuery struct {
	// Name is the identifier used to run the query (dfetch run <name>).
	Name string `yaml:"name"`
	// Description is a short human-readable summary shown by `dfetch queries`.
	Description string `yaml:"description"`
	// Params are the named bind parameters (:name) the SQL references, in the
	// order positional CLI arguments are bound to them.
	Params []string `yaml:"params"`
	// Columns is the default set of output columns; empty means all columns.
	Columns []string `yaml:"columns"`
	// SQL is the query body, run with Params bound as SQLite parameters.
	SQL string `yaml:"sql"`
}

SavedQuery is a reusable, named SQL query stored in the config. Params lists the named bind parameters the SQL references (as :name), in the positional order they are supplied on the command line. Columns is the default output projection; an empty list means every column the query produces.

type SourceConfig

type SourceConfig struct {
	// Name is the SQL schema referenced in queries (e.g. "github" in
	// github.issues).
	Name string `yaml:"name"`
	// Type selects the registered connector implementation (e.g. "github").
	Type string `yaml:"type"`
	// Params holds connector-specific options.
	Params map[string]any `yaml:"params"`
}

SourceConfig binds a SQL schema name to a configured connector.

Jump to

Keyboard shortcuts

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