fix(cli): stop flag defaults from clobbering config-file values - #5
Open
fiskhest wants to merge 1 commit into
Open
fix(cli): stop flag defaults from clobbering config-file values#5fiskhest wants to merge 1 commit into
fiskhest wants to merge 1 commit into
Conversation
The -F/--use-system-fonts, -N/--no-special-keys, and -Y/--no-symbols flags defaulted to False/True (not None), so _get_config() could not distinguish 'flag absent' from 'flag explicitly given' and always overwrote the values loaded from the config file. As a result a config like output.style.use_system_fonts: true was silently ignored unless -F was passed on the command line. Make the flags tri-state (None = not given): - cli.py: click options default to None; generate() and the generate_keymap() call site pass None through for absent flags - data/cli.py: OutputFiles.use_system_fonts defaults to None - keymap_generator.py: _get_config() only applies use_system_fonts, show_special_keys_legend, and show_symbol_legend when not None; generate_keymap() widens the two legend params to bool | None - exporter: save_drawings() takes the resolved use_system_fonts value so cairo/PNG export honors the config too Adds unit tests for the _get_config() precedence matrix and CLI flag propagation (tests/unit/application/test_keymap_generator.py, tests/unit/test_cli.py, tests/unit/data/test_cli.py).
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.
PR: fix(cli): stop flag defaults from clobbering config-file values
Base branch:
mainlineBranch:
fix/cli-flag-config-overridesCommit:
e8930a8(patch:/tmp/opencode/skim-fix.patch)Summary
When a config file is loaded with
skim generate -c <file>, three CLI flagsunconditionally overwrite the corresponding config-file values even when the
flag is not passed on the command line:
-F/--use-system-fonts-> clobbersoutput.style.use_system_fonts-N/--no-special-keys-> clobbersoutput.style.legend_tables.macros/tap_dances.show-Y/--no-symbols-> clobbersoutput.style.legend_tables.symbols.showBecause the flags defaulted to
False/True(notNone), "flag absent" wasindistinguishable from "user explicitly passed the default", so
_get_config()had no way to know it should keep the config value.Repro
skim generate -c skimconfig.yaml -k keyboard.kbi -o layout/ --layer 0-3 grep -c @font-face layout/keymap-layer-1.svg # -> 5 (fonts embedded anyway)Expected:
0(config honored without-F). Same forlegend_tables.*.show: falsevs-N/-Y.Fix
Make the three flags tri-state (
None= not given) and only apply them in_get_config()when notNone.src/skim/cli.py—--use-system-fonts,-N/--no-special-keys,-Y/--no-symbolsclick options nowdefault=None;generate()signatureand the
generate_keymap()call site passNonethrough for absent flags.src/skim/data/cli.py—OutputFiles.use_system_fontsdefaults toNone.src/skim/application/keymap_generator.py—_get_config()only appliesuse_system_fonts,show_special_keys_legend, andshow_symbol_legendwhen the argument is not
None;generate_keymap()widens the two legendparams to
bool | None.src/skim/application/exporter/__init__.py—save_drawings()now takesthe resolved
use_system_fontsvalue (previously it re-read the raw CLIvalue, so cairo/PNG export would ignore the config).
Tests
tests/unit/application/test_keymap_generator.py— precedence matrix for_get_config(): config value preserved when flag absent; explicitTrue/Falsestill wins.tests/unit/test_cli.py— absent flags propagate asNone;-F,-N,-Ypropagate their values.tests/unit/data/test_cli.py—OutputFiles.use_system_fontsdefault isnow
None.Verification
uv run pytest tests/unit— 1410 passed, 1 skipped (81.61% coverage, meets 80%)uv run ruff check src tests— cleanuv run ruff format --check src tests— cleanuv run basedpyright src— 0 errorsuse_system_fonts: true, no flag ->@font-facecount 0-Fflag ->@font-facecount 0@font-facecount 5 (defaults unchanged)