Module query

Source
Expand description

§Theme Query Command

The query command retrieves specific values from a configuration file. This is useful for shell scripts, debugging, and integration with other tools.

§Usage

# Query a specific value
fernctl query colors.background

# Query from a specific config file
fernctl query bar.height --config ./my-config.toml

# Use in shell scripts
ACCENT=$(fernctl query colors.accent)
echo "Accent color is: $ACCENT"

§Query Paths

Values are addressed using dot-separated paths that mirror the configuration structure:

config.toml                        Query Path
───────────                        ──────────
[colors]
background = "#1e1e2e"      →     colors.background
accent = "#89b4fa"          →     colors.accent

[bar]
height = 32                 →     bar.height
position = "top"            →     bar.position

[typography]
family = "Inter"            →     typography.family

§Available Paths

§Theme

PathTypeDescription
variantstringTheme variant (“dark” or “light”)

§Colors

PathTypeDescription
colors.backgroundhexPrimary background color
colors.foregroundhexPrimary text color
colors.accenthexAccent/highlight color
colors.surfacehexSurface/card background
colors.errorhexError state color
colors.warninghexWarning state color
colors.successhexSuccess state color
colors.infohexInformational state color

§Bar

PathTypeDescription
bar.heightintegerBar height in pixels
bar.positionstringBar position (“top” or “bottom”)

§Typography

PathTypeDescription
typography.familystringPrimary font family
typography.monostringMonospace font family

§Radius

PathTypeDescription
radius.smintegerSmall border radius (px)
radius.mdintegerMedium border radius (px)
radius.lgintegerLarge border radius (px)

§Output Format

Query results are printed to stdout without any decoration, making them suitable for shell script consumption:

$ fernctl query colors.accent
#89b4fa

$ fernctl query bar.height
32

§Error Handling

If a path is not recognized, the command prints available paths to stderr and exits with code 0 (this is intentional — unknown paths are not errors, they might be from a newer config version).

$ fernctl query colors.prple
Unknown path: colors.prple

Available paths:
  colors.background, colors.foreground, colors.accent, ...

Did you mean: colors.purple?

§Programmatic Usage

ⓘ
use fernctl::commands::query::{run, QueryOptions};
use fernctl::adapters::TomlConfigAdapter;

let adapter = TomlConfigAdapter::new();
let options = QueryOptions { verbose: false };

if let Some(value) = run(&config_path, "colors.accent", options, &adapter)? {
    println!("Accent: {}", value);
}

Structs§

QueryOptions
Options for the query command.

Constants§

AVAILABLE_PATHS
All available query paths.

Functions§

find_similar_paths
Finds similar paths for “did you mean?” suggestions.
print_available_paths
Prints help text showing all available query paths.
run
Queries a theme value by path.