fix(cli): Wire dialect flag through config merge for all commands#83
Merged
Conversation
The `--dialect` flag on render/inspect/export/doc/lint was declared with `default_value = "auto"`, so `args.dialect` was always `Some(Auto)` and TOML `[command] dialect = "..."` was silently ignored. Only `diff` had the flag wired through `merge_*_args` correctly. - Change `dialect` on five `XxxArgs` to `Option<DialectArg>` without a clap default. - Add `dialect: Option<DialectArg>` to `RenderConfig`, `InspectConfig`, `ExportConfig`, `DocConfig`, `LintConfig`. - Add `dialect: DialectArg` to each `MergedXxxConfig` and populate it in every `merge_*_args` via `args.dialect.or(self.xxx.dialect).unwrap_or_default()`. - Switch each command from `args.dialect.into()` to `merged.dialect.into()`. - Refresh CLI help snapshots (no more `[default: auto]`) and the unknown-field snapshot (now lists `dialect`).
Expose the new `dialect` TOML key in public docs and the full fixture, and add regression tests proving `[render|inspect|export|doc|lint] dialect = ...` is picked up when `--dialect` is unset (and that CLI still wins when both are set).
Code Metrics Report
Details | | main (e359a57) | #83 (25b6c0e) | +/- |
|---------------------|----------------|---------------|--------|
+ | Coverage | 94.6% | 94.6% | +0.0% |
| Files | 77 | 77 | 0 |
| Lines | 33588 | 33774 | +186 |
+ | Covered | 31795 | 31981 | +186 |
+ | Test Execution Time | 3m18s | 1m26s | -1m52s |Code coverage of files in pull request scope (94.6% → 95.2%)
Reported by octocov |
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
[render]/[inspect]/[export]/[doc]/[lint] dialect = "..."in the TOML config being silently ignored.clap's
default_value = "auto"on--dialectmeant the CLI always supplied a concrete value, so theargs.dialect.or(config.dialect)merge never sawNoneand the file-level setting was shadowed.--dialecttoOption<DialectArg>and resolve the effective dialect throughthe existing
merge_*_argspath, restoring the documented precedence (defaults → config → CLI).diffalready worked this way and is unchanged.
docs/configuration.mdand the full fixture, and add regression tests so the mergepath can't silently regress again.
Changes
--dialectanOption<DialectArg>on render/inspect/export/doc/lint and merge it viaargs.dialect.or(self.<cmd>.dialect).unwrap_or_default(); carry the resolved value onMergedXxxConfigandfeed
merged.dialect.into()into input resolution.deny_unknown_fieldssnapshots now that--dialectno longer advertises[default: auto]and the accepted field list includesdialect.dialectrow to every command table indocs/configuration.mdand populatefixtures/config/valid_full.toml/ theconfig.rsmodule doc with the new key.[<cmd>] dialect = "..."is honored when--dialectis unset and that the CLI still wins when both are set.