Skip to content

設定ファイルの項目を CLI から打ち消せるようにする (設定の可逆化)#48

Merged
TwoSquirrels merged 10 commits into
mainfrom
feat/reversible-config
Jul 11, 2026
Merged

設定ファイルの項目を CLI から打ち消せるようにする (設定の可逆化)#48
TwoSquirrels merged 10 commits into
mainfrom
feat/reversible-config

Conversation

@TwoSquirrels

@TwoSquirrels TwoSquirrels commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Closes #24

概要

設定ファイルに書いた項目を CLI から打ち消せない非可逆性 (#24) を解消する。「config に置ける項目は CLI で必ず打ち消せる」という不変条件を全項目で成立させ、重ね方は項目の型ごとに定める: スカラー = 上書き、bool = --x/--no-x ペア (後勝ち)、集合 = 加算 + 打ち消し、順序付きリスト = 追記。

変更内容

  • --no-embed を追加--embed と後勝ちのペアにし、解決順を「CLI で明示 > config > 組み込み既定」に (従来は OR で config の embed = true を戻せなかった)
  • --keep を加算化し --no-keep を追加 ⚠️ breaking — 実効 keep = (config の keep ∪ --keep) − --no-keep。同じ ID は順序に依らず --no-keep が勝つ。-k std の書き忘れで std が全展開される footgun が消え、--no-keep std で CLI から keep を空にもできる
  • std 抜けの警告 — 実効 keep に std が無ければ stderr に警告。ただし CLI で --no-keep std と明示された場合は意図とみなし抑制 (書き忘れは防護、明示は尊重)
  • -- のコンパイラオプションを config への追記に変更 ⚠️ breaking — 上書きの意味論はコンパイラの後勝ち (-std 等) や -U に委譲。従来の置き換え方式にあった「-- -O0-std=gnu++17 まで消える」隠れバグも解消
  • --no-config を追加 — 「設定ファイルが 1 つも見つからない環境と完全に同一の挙動」と定義する横断的な脱出ハッチ。追記方式で打ち消せない config のフラグ (-I 等) もこれで外せる
  • ドキュメント更新 — README・cheatsheet・spec の en/ja 6 ファイル。spec の「設定の解決」を型ごとの重ね方で書き直し、cheatsheet の「-k で std が展開される」FAQ は config の keep 書き忘れの FAQ に改稿、「keep を今回だけ展開したい → --no-keep」レシピを追加

config ファイル側の意味論は従来通り (各項目は宣言的な全量指定でマージしない)。バージョン番号はこの PR では触らない (breaking 変更を含むため、次リリースは v2.0 を想定)。

検証

  • clippy 警告ゼロ、全テスト (単体 175 + CLI 17 + libraries 5) 通過
  • 実バイナリで一連の挙動を end-to-end 確認:
    • 既定で std keep・警告なし / -k mylib で std も残る (加算)
    • --no-keep std で std が展開され、警告も抑制される
    • config の keep に std 抜け → 警告が出る
    • config の embed = true--no-embed で打ち消せる
    • --no-config で設定ファイルのある環境が無い環境と同一挙動になる
    • -- -DEXTRA 指定後も既定の -DONLINE_JUDGE が生きる (追記)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added --no-keep for one-run unkeeping, with defined precedence over keep settings.
    • Added --embed/--no-embed, where --no-embed cancels configured embedding.
    • Added --no-config to ignore .risundlerc.toml entirely.
    • Updated CLI/config behavior for options, library keep/expansion, and added a warning when the standard library isn’t kept unintentionally.
  • Documentation

    • Updated English/Japanese README, cheatsheets, and spec with the new flags and configuration resolution rules.

TwoSquirrels and others added 4 commits July 11, 2026 11:20
…celled

`embed` was OR-merged with the config, so `embed = true` in
.risundlerc.toml was irreversible from the CLI (#24). Treat the pair as
an Option<bool> resolved last-wins, preferring an explicit CLI flag over
the config over the builtin default.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A single -k used to replace the default keep = ["std"] wholesale, so
forgetting -k std silently expanded the entire standard library (#24).
The effective set is now (config keep ∪ --keep) − --no-keep; --no-keep
wins over --keep regardless of order, erring toward the self-contained
(expanded) output. --no-keep std restores the ability to empty the set
from the CLI, which previously required the accidental -k '' trick.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Forgetting "std" in the config's keep (or --no-keep'ing it by accident
elsewhere) silently emits a huge bundle that only surfaces at submission
size limits. Warn on absence, but stay quiet when the CLI passed
--no-keep std explicitly: absence is guarded, explicit intent is
respected (#24).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…eplacing

Passing any option after -- used to discard the whole configured list,
so `-- -O0` also dropped -std=gnu++17 (#24). Append the CLI options and
delegate override semantics to the compiler's own last-wins rules
(-std=... beats an earlier one, -U kills -D); risundle does not
interpret flags itself.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c0cd0877-c78f-4464-9fc7-48952d94c3cb

📥 Commits

Reviewing files that changed from the base of the PR and between ac7d581 and 9bced9e.

📒 Files selected for processing (3)
  • README.ja.md
  • README.md
  • src/cli.rs
✅ Files skipped from review due to trivial changes (1)
  • README.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/cli.rs
  • README.ja.md

📝 Walkthrough

Walkthrough

The bundling CLI now supports reversible keep, embed, and configuration overrides. Settings resolution merges CLI and config values by field type, warns when std is unintentionally absent, and is covered by expanded tests and documentation.

Changes

Configuration resolution

Layer / File(s) Summary
CLI override contract
src/cli.rs
Adds --no-keep, --no-embed, and --no-config, with last-flag-wins embed resolution and unit coverage.
Settings merge and warning flow
src/commands/bundle.rs
Resolves CLI/config values using additive keep, subtractive --no-keep, appended compiler options, optional embed overrides, config bypass, and std warnings.
Documented configuration semantics
README*, docs/cheatsheet*, docs/spec*
Documents the new flags, configuration discovery, precedence rules, keep behavior, embed cancellation, and std warnings.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant Bundle
  participant Settings
  participant Config
  CLI->>Bundle: Parse override flags
  Bundle->>Settings: Resolve CLI and config inputs
  Settings->>Config: Load configuration unless --no-config
  Config-->>Settings: Return config values
  Settings-->>Bundle: Return effective settings
  Bundle->>Bundle: Warn if std is not kept
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: making config settings reversible from the CLI.
Linked Issues check ✅ Passed The PR implements the requested CLI reversibility for embed, keep, options, and no-config, plus the std warning and docs updates.
Out of Scope Changes check ✅ Passed The code and documentation changes all align with the linked issue’s configuration-reversal scope.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/reversible-config

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

TwoSquirrels and others added 4 commits July 11, 2026 11:30
Appending cannot cancel every kind of configured flag (a config -I, for
example), so provide one cross-cutting escape hatch defined as: behave
exactly as if no config file were found. This keeps the effective
settings reachable from builtin defaults via the CLI alone, for any
future config key (#24).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Document the #24 semantics across README, cheatsheet, and spec (en/ja):
--keep is now additive with --no-keep as its inverse, CLI compiler
options append to the configured ones, --no-embed cancels a configured
embed, and --no-config behaves exactly as if no config file were found.
The spec also records the std-missing warning and its suppression, and
the cheatsheet FAQ about -k dropping std is reworked into the config
keep footgun it has become.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
"pre-tree-shaking code" could be read as the preprocessed-but-unshaken
output; the attachment is the untouched text of the input file.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@TwoSquirrels TwoSquirrels changed the title Feat/reversible config 設定ファイルの項目を CLI から打ち消せるようにする (設定の可逆化) Jul 11, 2026
@TwoSquirrels TwoSquirrels marked this pull request as ready for review July 11, 2026 03:04
@TwoSquirrels TwoSquirrels requested a review from Copilot July 11, 2026 03:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses non-reversible configuration layering by ensuring every config-file setting can be explicitly overridden (or negated) from the CLI, with merge semantics defined per setting type (scalar/bool/set/list). It introduces new CLI flags and updates resolution logic, tests, and documentation accordingly.

Changes:

  • Add reversible CLI overrides: --no-embed, additive --keep plus subtractive --no-keep, and global escape hatch --no-config.
  • Change compiler options layering so CLI options after -- are appended to configured options (instead of replacing).
  • Add warnings when std is missing from effective keep (suppressed when explicitly removed via --no-keep std) and update specs/cheatsheets.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/commands/bundle.rs Updates settings resolution to support --no-config, additive/subtractive keep, appended options, and std-missing warning.
src/cli.rs Adds new CLI flags (--no-keep, --no-embed, --no-config) and an embed_override() helper with tests.
README.md Documents new CLI flags and updated layering semantics.
README.ja.md Japanese documentation updates for new flags and layering semantics.
docs/spec.md Formalizes type-based layering rules and --no-config semantics in the spec.
docs/spec.ja.md Japanese spec update mirroring the new layering rules.
docs/cheatsheet.md Updates recipes/FAQ to match additive keep, --no-keep, and --no-embed behavior.
docs/cheatsheet.ja.md Japanese cheatsheet update mirroring the new behaviors and recipes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/cli.rs Outdated
Comment thread src/cli.rs
Comment thread README.md Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/cli.rs`:
- Around line 33-39: Add the `overrides_with = "embed"` argument attribute to
the `no_embed` field in the CLI arguments definition, matching the existing
override configuration on `embed`, so specifying both flags makes the last one
take precedence and keeps `embed_override()` consistent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9838fa1f-c33d-4e99-9b7e-5cc1dd997314

📥 Commits

Reviewing files that changed from the base of the PR and between a41f974 and ac7d581.

📒 Files selected for processing (8)
  • README.ja.md
  • README.md
  • docs/cheatsheet.ja.md
  • docs/cheatsheet.md
  • docs/spec.ja.md
  • docs/spec.md
  • src/cli.rs
  • src/commands/bundle.rs

Comment thread src/cli.rs
TwoSquirrels and others added 2 commits July 11, 2026 14:13
One-sided overrides_with already resolves last-wins in both directions
(verified in review), so this is intent documentation, not a bug fix.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
"cancels the config file" read as if the whole file were ignored, which
is --no-config's job.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@TwoSquirrels TwoSquirrels requested a review from Copilot July 11, 2026 05:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@TwoSquirrels TwoSquirrels merged commit a2dd98e into main Jul 11, 2026
10 checks passed
@TwoSquirrels TwoSquirrels deleted the feat/reversible-config branch July 11, 2026 05:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.risundlerc.toml の一部の項目が非可逆

2 participants