Documentation
¶
Overview ¶
Package config loads dfetch's data source configuration.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultPath ¶
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 ¶
Load reads the config from path. If path is empty, the default path is discovered (see discoverPath: ./dfetch.yaml, then $XDG_CONFIG_HOME/dfetch/dfetch.yaml, then ~/dfetch.yaml). A missing default config yields an empty Config rather than an error, so dfetch can run without a config file present.
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.