Repository navigation
Add rfl::cli::KeepEmptyItems to read empty list items as missing values - #32
Open
clockblocker wants to merge 1 commit into
Open
clockblocker wants to merge 1 commit into
clockblocker wants to merge 1 commit into
Conversation
clockblocker
force-pushed
the
cli-keep-empty-items
branch
from
November 14, 2026 13:01
8ea1bc9 to
e8ea83e
Compare
clockblocker
force-pushed
the
cli-keep-empty-items
branch
from
November 15, 2026 08:21
e8ea83e to
82681ef
Compare
clockblocker
force-pushed
the
wave-base-10
branch
2 times, most recently
from
November 16, 2026 05:18
30b4ec4 to
b06e850
Compare
clockblocker
force-pushed
the
cli-keep-empty-items
branch
2 times, most recently
from
November 17, 2026 04:36
9b492a6 to
fb28a2e
Compare
clockblocker
force-pushed
the
wave-base-10
branch
from
November 17, 2026 05:11
bed2129 to
d927002
Compare
clockblocker
force-pushed
the
cli-keep-empty-items
branch
3 times, most recently
from
November 17, 2026 07:15
9d84085 to
dcc0f15
Compare
rfl::cli skips empty items in split lists, so `--tags=a,,b` is read as
[a, b]. With rfl::cli::KeepEmptyItems, each empty item is kept as a
missing value at its index, and the element type decides, as it does for
a missing field: std::optional<T> elements become std::nullopt,
rfl::DefaultVal<T> elements become T{}, smart pointers become null, and
types that need a value fail with "Empty item at index 1.",
located at ["tags", 1] in rfl::Error::details(). The index counts the
items of every occurrence of a repeated option or list positional.
The setting only applies to lists that are split: with
ListDelimiter<"">, every occurrence is one item as it is, even if it is
empty, so combining the two is a compile-time error.
The Reader keeps empty pieces when splitting and passes each one on as
a variable without a value. A Parser specialization for DefaultVal with
the CLI reader returns the default for it, and one for std::wstring
rejects it, as ParserWString would otherwise read it as "". Without the
setting, nothing changes, and other formats ignore it.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
clockblocker
force-pushed
the
wave-base-10
branch
from
November 17, 2026 09:51
135f510 to
2945a05
Compare
clockblocker
force-pushed
the
cli-keep-empty-items
branch
from
November 17, 2026 09:51
dcc0f15 to
e3e36d6
Compare
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
Adds the opt-in
rfl::cli::KeepEmptyItemsprocessor so empty items in split CLI lists (--tags=a,,b) are preserved as missing elements instead of silently dropped.Example
// Input: --tags=a,,b with rfl::cli::read<Config, rfl::cli::KeepEmptyItems>(...)std::vector<std::optional<std::string>>{"a", std::nullopt, "b"}std::vector<rfl::DefaultVal<std::string>>{"a", "", "b"}std::vector<std::shared_ptr<std::string>>{"a", nullptr, "b"}std::vector<std::string>/std::vector<int>Failed to parse field 'tags': Empty item at index 1.Key details
ListDelimiter<"">withKeepEmptyItemsis a compile-timestatic_assert.--tags=is still an empty list; whitespace (" ") is a non-empty item; repeated options and list positionals report the combined index inrfl::Error::details().cli.md("Empty list items").(Same
rfl::cli::Settingsvs processor API question as #30.)AI-authored. Depends on: #26, #30, #36.