Repository navigation
feat: add ignore state to ActionResult and nargs context to ActionCtx - #34
Merged
Merged
Conversation
ActionResult gains a 3rd state (ok / error / ignore): - ignore stops downstream pipeline steps (no-op to storage) - error now passes through to downstream steps instead of bypassing - have_value(), is_ignored(), ignore() factory, propagate<U>() added ActionCtx gains nargs, value_index, total_values fields (invoke_count removed). Action::invoke bypasses on ignore, passes error through to each step. All built-in steps guard with have_value() to propagate error/ignore correctly. Adds conversion::DefaultMissingValue<V> for optional-value option support. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Parameter 'nargs' was shadowing static member 'nargs', causing MSVC warning C4458 (treated as error with /WX). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the action pipeline and argument invocation model to support a new “ignore” result state and richer per-invocation context (nargs/value indices), enabling optional-entry pipelines (via std::optional<string_view>) and new behaviors like default injection for flag-style invocations.
Changes:
- Adds a 3-state
ActionResult(ok/error/ignore), propagation helpers, and updates action pipeline invocation to short-circuit only onignore. - Extends
ActionCtxwithnargs,value_index, andtotal_values, and threads these through option/flag/positional invocation. - Adds
conversion::DefaultMissingValueand updates built-in conversion/validation/pack steps to guard onhave_value()and propagate error/ignore.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| include/cli/action.hh | Introduces ignore semantics, updates pipeline invocation rules, adds optional-entry support and DefaultMissingValue, and updates built-in steps for propagation. |
| include/cli/argument.hh | Updates argument invocation to pass nargs/value indices and to dispatch optional-entry pipelines. |
| include/cli/parser.hh | Threads nargs/value index metadata from token dispatch into argument invocation, including env fallback paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Rename `pack::store_into` to `pack::write_to` across the library, tests, and documentation. Refactor `ArgImpl` and `PositionalImpl` to store metadata in an internal `ArgParameter` struct instead of flat fields, providing explicit getters for access. Add program name accessors to the `Parser` class. BREAKING CHANGE: pack::store_into is renamed to pack::write_to.
Consolidate invoke_flag into invoke_action by using std::optional for the input text. This simplifies the parser's dispatch logic and provides a single entry point for all option types. Additionally, ensure default values are correctly initialized in ArgImpl and PositionalImpl constructors, and refactor for_each_field to use index sequences and constexpr.
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
ActionResult<T>gains a 3rd stateignore(alongsideok/error) viaenum class Stateignorestops downstream pipeline steps as a no-op — nothing is written to storageerrornow passes through to downstream steps instead of being bypassedhave_value(),is_ignored(),ignore()factory,propagate<U>()ActionCtxgainsnargs,value_index,total_values(replacesinvoke_count)nargs: number of values in this option occurrencevalue_index: 0-based index of the current value within this occurrencetotal_values: cumulative values across all occurrencesAction<>::invokeupdated: bypasses onignore, passeserrorthrough to each stepconversion,validation,pack) updated to guard withhave_value()and propagate error/ignore correctlyconversion::DefaultMissingValue<V>step: acceptsoptional<string_view>as pipeline entry, injects compile-time default for flag-only invocations (nargs==0), returnsignorewhen a value invocation is expectedargument.hh:invoke_action/invoke_flagupdated to passnargs/value_index, and to useoptional<string_view>entry whenAction::entry_is_optionalis true🤖 Generated with Claude Code