Skip to content

Add grut config get command to read a single config value#344

Open
jongio wants to merge 1 commit into
mainfrom
idea/config-get
Open

Add grut config get command to read a single config value#344
jongio wants to merge 1 commit into
mainfrom
idea/config-get

Conversation

@jongio

@jongio jongio commented Jul 19, 2026

Copy link
Copy Markdown
Owner

What

Adds grut config get <key>, a scripting-friendly way to read one resolved config value by dotted key.

  • Scalars print as a bare value so they pipe cleanly: grut config get git.default_branch prints main.
  • Sections print as TOML: grut config get preview prints the whole preview table.
  • Unknown keys print Error: unknown config key: <key> and exit 1 (usage is silenced so scripts get a clean one-line error).

Defaults are applied, so a key the user never set still returns the effective value. The lookup round-trips the resolved config through TOML into a generic map, so key names track the existing TOML tags with no second source of truth.

Deadlock fix

Every grut config subcommand (including the existing config check) deadlocked at runtime before this change. main.go wrapped slog's built-in default handler in the crash-tail handler and re-set it as the default. slog.SetDefault rewires the stdlib log package back through the new default, so the old bridge handler formed a cycle that hung the first time anything logged at INFO or above. config.Load triggers that through icon-mode detection. The crash tail now feeds from a concrete discard handler (matching how the TUI sets up logging), so the ring buffer still captures entries for crash reports without writing to the console.

Tests

  • Unit tests for scalar, nested scalar, section, unknown top-level key, unknown nested key, descending into a scalar, load error, and slice output.
  • go build ./..., go vet ./..., mage lint (0 issues), and mage deadcode (OK) all pass.

Closes #341

Add a scripting-friendly subcommand that prints a single resolved config
value addressed by a dotted key (for example `git.default_branch`, or a
whole section like `preview`). Scalars print as a bare value so they pipe
cleanly into scripts; sections print as TOML. Unknown keys exit non-zero.

The lookup round-trips the resolved Config through TOML into a generic
map, so key names stay in sync with the existing TOML tags and there is
no second source of truth.

Also fix a pre-existing deadlock that hung every `grut config`
subcommand at runtime. main.go wrapped slog's built-in default handler in
the crash-tail handler and re-set it as the default. slog.SetDefault
rewires the stdlib log package back through the new default, so the old
bridge handler formed a cycle that self-deadlocked the first time
anything logged at INFO or above (config.Load triggers this through
icon-mode detection). The crash tail now feeds from a concrete discard
handler, matching how the TUI configures logging, so the ring buffer
still captures entries for crash reports without writing to the console.

Closes #341

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 07f6eb49-d72f-4f2a-9285-065b5d835f5b
@jongio jongio added the idea Feature idea from the idea pipeline label Jul 19, 2026
@jongio jongio self-assigned this Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

idea Feature idea from the idea pipeline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a grut config get command to read a single config value

1 participant