Repository navigation
fix(config): coerce config set values and keep config get in lockstep - #96
Merged
Merged
Conversation
dot config set delivers every value as a string, but most typed setters type-asserted the raw argument, so boolean and integer keys could never be set from the CLI (symlinks.backup, output.verbosity, doctor.*, and friends all failed with "value must be bool"). Route every boolean field through toBool, add toInt for the integer fields, and validate field names before coercing so an unknown field is reported as unknown. config get had drifted the other way: its hand-written getter map knew only 15 keys, so a freshly set key read back as "unknown config key". The getter map now covers the full settable surface, completion derives from it, and a round-trip test walks getValidConfigKeys so the two surfaces cannot drift apart silently again. symlinks.backup_dir, which completion offered but the setter rejected, is now settable too. Fixes #94
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.
Summary
Fixes #94.
dot config setdelivered every value as a string, but most typed setters type-asserted the raw argument, so boolean and integer keys could never be set from the CLI (symlinks.backup,output.verbosity,operations.*,packages.*,doctor.*,experimental.*). Every boolean field now routes throughtoBool(which also tolerates surrounding whitespace), integer fields through a newtoInt, and field names are validated before coercion sodoctor.bogusis reported as an unknown field rather than a value error.config gethad drifted the other way: its getter map knew only 15 keys, so a freshly set key read back as "unknown config key". The getter map now covers the full settable surface and completion derives from it.symlinks.backup_dirwas offered by completion but rejected by the setter; it is now settable.Tests
TestWriter_UpdateCoercesCLIStrings: every typed key set from its CLI string form, round-tripped through a real write/load.TestConfigCommand_EveryCompletedKeyRoundTrips: walksgetValidConfigKeys()and drives set -> load -> get for each, so the getter and setter surfaces cannot drift apart silently again.Full suite green with race and coverage; golangci-lint clean.