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
| Path | Type | Description |
|---|---|---|
variant | string | Theme variant (“dark” or “light”) |
§Colors
| Path | Type | Description |
|---|---|---|
colors.background | hex | Primary background color |
colors.foreground | hex | Primary text color |
colors.accent | hex | Accent/highlight color |
colors.surface | hex | Surface/card background |
colors.error | hex | Error state color |
colors.warning | hex | Warning state color |
colors.success | hex | Success state color |
colors.info | hex | Informational state color |
§Bar
| Path | Type | Description |
|---|---|---|
bar.height | integer | Bar height in pixels |
bar.position | string | Bar position (“top” or “bottom”) |
§Typography
| Path | Type | Description |
|---|---|---|
typography.family | string | Primary font family |
typography.mono | string | Monospace font family |
§Radius
| Path | Type | Description |
|---|---|---|
radius.sm | integer | Small border radius (px) |
radius.md | integer | Medium border radius (px) |
radius.lg | integer | Large 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§
- Query
Options - 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.