Add grut config get command to read a single config value#344
Open
jongio wants to merge 1 commit into
Open
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
grut config get <key>, a scripting-friendly way to read one resolved config value by dotted key.grut config get git.default_branchprintsmain.grut config get previewprints the whole preview table.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 configsubcommand (including the existingconfig 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.SetDefaultrewires the stdliblogpackage 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.Loadtriggers 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
go build ./...,go vet ./...,mage lint(0 issues), andmage deadcode(OK) all pass.Closes #341