Skip to content

feat(option): add skip_excluded to consume hidden options silently - #182

Closed
Seele-Official wants to merge 2 commits into
clice-io:mainfrom
Seele-Official:feat/option-skip-excluded
Closed

feat(option): add skip_excluded to consume hidden options silently#182
Seele-Official wants to merge 2 commits into
clice-io:mainfrom
Seele-Official:feat/option-skip-excluded

Conversation

@Seele-Official

@Seele-Official Seele-Official commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

When an option is excluded by visibility/include/exclude flags and skip_excluded is enabled, the parser consumes the option exactly as if it were accepted (including joined/separate/remaining values) but never yields a ParsedArg and never reports a missing-value error. Excluded matches still lose to visible duplicates with the same spelling, and grouped short options expand through hidden flags without output.

Wire the option unit tests into unit_tests (they were gated on an undeclared 'option' config and the .cpp file was not matched by the deco glob) and add coverage for the new behavior.

Summary by CodeRabbit

  • New Features

    • Added an option to silently consume arguments hidden by visibility or flag filters.
    • Hidden options can now include joined or separate values and grouped flags without appearing in parsed results or triggering missing-value errors.
    • Visible options take precedence when duplicate spellings are present.
  • Bug Fixes

    • Improved handling of excluded options during parsing, fallback matching, and known-option checks.
    • Expanded automated coverage for filtered, grouped, duplicate, and value-bearing options.

When an option is excluded by visibility/include/exclude flags and
skip_excluded is enabled, the parser consumes the option exactly as if
it were accepted (including joined/separate/remaining values) but never
yields a ParsedArg and never reports a missing-value error. Excluded
matches still lose to visible duplicates with the same spelling, and
grouped short options expand through hidden flags without output.

Wire the option unit tests into unit_tests (they were gated on an
undeclared 'option' config and the .cpp file was not matched by the
deco glob) and add coverage for the new behavior.
@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

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 Plus

Run ID: fa6b7116-ce79-4418-8171-7cde2d9bba2e

📥 Commits

Reviewing files that changed from the base of the PR and between b7e7eb0 and f846c90.

📒 Files selected for processing (2)
  • src/deco/option/table.cc
  • tests/unit/deco/option_tests.cpp
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/deco/option/table.cc
  • tests/unit/deco/option_tests.cpp

📝 Walkthrough

Walkthrough

ParseOptions::skip_excluded enables silent consumption of options excluded by visibility or flag filters. The parser handles values, grouped flags, duplicate spellings, missing values, iterators, and related unit-test wiring.

Changes

Excluded option parsing

Layer / File(s) Summary
Excluded match tracking
include/kota/deco/option/table.h, src/deco/option/table.cc
ParseOptions adds skip_excluded. Scanning records excluded matches, preserves exclusion state, and prefers visible matches with equal spellings or lengths.
Silent parse consumption
src/deco/option/table.cc
Parsing and iteration consume excluded options, values, and grouped flags without returning arguments or emitting missing-value errors.
Behavior coverage and test wiring
tests/unit/deco/option_tests.cpp, xmake.lua
Tests cover hidden options, grouped parsing, missing values, duplicate spellings, tablegen lookup, and greedy-unknown boundaries. Deco tests are included whenever deco is enabled.

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

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant OptTable
  participant OptionIterator
  Caller->>OptTable: parse with skip_excluded enabled
  OptTable->>OptTable: scan visible and excluded matches
  OptTable->>OptionIterator: consume excluded option and value
  OptionIterator-->>Caller: yield visible arguments only
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 and concisely describes the main change: adding skip_excluded to consume hidden options silently.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/deco/option/table.cc (1)

409-435: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Continue scanning past an excluded match to find a visible duplicate.

is_known_option returns as soon as it finds the first matching entry in range. scan_and_accept was extended in this PR to keep scanning past an excluded match so a visible option with the same spelling can still win (see the "Keep scanning" comment at Lines 327-338). is_known_option was not given the same treatment.

If a hidden option's spelling collides with a later visible option's spelling in option_infos, and skip_excluded is false, this function returns false for that spelling even though a visible duplicate exists further in the range and would actually be matched by scan_and_accept. consume_unknown_values (used with greedy_unknown) then incorrectly swallows that argument as a value of a preceding unknown/greedy option instead of treating it as a known-option boundary.

🐛 Proposed fix to keep scanning past excluded entries
         OptionRef opt(*s, table);
-        if(options.excludes(opt))
-            return options.skip_excluded;
-        return true;
+        if(options.excludes(opt)) {
+            if(options.skip_excluded)
+                return true;
+            continue;
+        }
+        return true;
     }
     return false;
🤖 Prompt for 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.

In `@src/deco/option/table.cc` around lines 409 - 435, Update is_known_option to
continue scanning after a matching option that options.excludes(opt) reports as
excluded, rather than immediately returning options.skip_excluded. Return true
when a later non-excluded duplicate is found, while preserving the existing
matching-kind and argument-length checks and returning the current skip_excluded
result only when no visible match remains.
🤖 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 `@tests/unit/deco/option_tests.cpp`:
- Around line 760-771: Sort the option entries used by the tablegen path in
kSkipOptInfos by the OptNameLess ordering before scan_and_accept applies
std::lower_bound, or provide a name-sorted array for that path. Preserve the
existing duplicate-visible option selection and ensure searches such as -d begin
at the correct range position.

---

Outside diff comments:
In `@src/deco/option/table.cc`:
- Around line 409-435: Update is_known_option to continue scanning after a
matching option that options.excludes(opt) reports as excluded, rather than
immediately returning options.skip_excluded. Return true when a later
non-excluded duplicate is found, while preserving the existing matching-kind and
argument-length checks and returning the current skip_excluded result only when
no visible match remains.
🪄 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 Plus

Run ID: e8a207e8-b509-4bb1-9864-1275309c6418

📥 Commits

Reviewing files that changed from the base of the PR and between c516e3a and b7e7eb0.

📒 Files selected for processing (4)
  • include/kota/deco/option/table.h
  • src/deco/option/table.cc
  • tests/unit/deco/option_tests.cpp
  • xmake.lua

Comment thread tests/unit/deco/option_tests.cpp

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b7e7eb0499

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/deco/option/table.cc Outdated
Comment thread src/deco/option/table.cc Outdated
… boundary

Two review findings on skip_excluded:

1. In grouped-short-option mode a later excluded duplicate could
   overwrite an earlier visible fallback (last-wins), so parsing -ab with
   a visible -a followed by a hidden -a dropped the visible -a. The
   fallback recording now keeps a visible candidate over an excluded
   duplicate, mirroring the non-grouped duplicate preference.

2. is_known_option returned immediately for the first excluded match,
   which changed the default (skip_excluded off) greedy-unknown
   behavior: with a hidden -x preceding a visible -x, --unknown -x
   swallowed -x as a value instead of treating it as a boundary. Excluded
   entries are skipped again unless skip_excluded is enabled, in which
   case they remain recognized boundaries.

Adds regression tests for both cases plus the all-excluded greedy case.
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.

1 participant