Skip to content

fix(cli): Wire dialect flag through config merge for all commands#83

Merged
mhiro2 merged 2 commits into
mainfrom
fix/lint-dialect-config-merge
Apr 24, 2026
Merged

fix(cli): Wire dialect flag through config merge for all commands#83
mhiro2 merged 2 commits into
mainfrom
fix/lint-dialect-config-merge

Conversation

@mhiro2

@mhiro2 mhiro2 commented Apr 24, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fix [render]/[inspect]/[export]/[doc]/[lint] dialect = "..." in the TOML config being silently ignored.
    clap's default_value = "auto" on --dialect meant the CLI always supplied a concrete value, so the
    args.dialect.or(config.dialect) merge never saw None and the file-level setting was shadowed.
  • Switch those five commands' --dialect to Option<DialectArg> and resolve the effective dialect through
    the existing merge_*_args path, restoring the documented precedence (defaults → config → CLI). diff
    already worked this way and is unchanged.
  • Document the key in docs/configuration.md and the full fixture, and add regression tests so the merge
    path can't silently regress again.

Changes

  • 132ce4d : fix(cli): wire dialect flag through config merge for all commands
    • Make --dialect an Option<DialectArg> on render/inspect/export/doc/lint and merge it via
      args.dialect.or(self.<cmd>.dialect).unwrap_or_default(); carry the resolved value on MergedXxxConfig and
      feed merged.dialect.into() into input resolution.
    • Refresh help and deny_unknown_fields snapshots now that --dialect no longer advertises [default: auto] and the accepted field list includes dialect.
  • be89a33 : docs(config): document dialect key and add merge regression tests
    • Add a dialect row to every command table in docs/configuration.md and populate
      fixtures/config/valid_full.toml / the config.rs module doc with the new key.
    • Add 10 regression tests (two per command) proving [<cmd>] dialect = "..." is honored when --dialect
      is unset and that the CLI still wins when both are set.

mhiro2 added 2 commits April 24, 2026 22:11
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).
@mhiro2 mhiro2 self-assigned this Apr 24, 2026
@mhiro2 mhiro2 added the bug Something isn't working label Apr 24, 2026
@github-actions

Copy link
Copy Markdown

Code Metrics Report

main (e359a57) #83 (25b6c0e) +/-
Coverage 94.6% 94.6% +0.0%
Test Execution Time 3m18s 1m26s -1m52s
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%)

Files Coverage +/- Status
crates/relune-cli/src/cli.rs 88.0% 0.0% modified
crates/relune-cli/src/commands/doc.rs 76.1% 0.0% modified
crates/relune-cli/src/commands/export.rs 92.1% 0.0% modified
crates/relune-cli/src/commands/inspect.rs 100.0% 0.0% modified
crates/relune-cli/src/commands/lint.rs 77.0% 0.0% modified
crates/relune-cli/src/commands/render.rs 98.4% 0.0% modified
crates/relune-cli/src/config.rs 96.4% +0.6% modified

Reported by octocov

@mhiro2
mhiro2 merged commit cf85e4b into main Apr 24, 2026
5 checks passed
@mhiro2
mhiro2 deleted the fix/lint-dialect-config-merge branch April 24, 2026 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant