Skip to content

feat: add ignore state to ActionResult and nargs context to ActionCtx - #34

Merged
gen740 merged 12 commits into
mainfrom
feat/action-result-ignore-state
May 11, 2026
Merged

gen740 merged 12 commits into
mainfrom
feat/action-result-ignore-state

Conversation

@gen740

@gen740 gen740 commented May 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • ActionResult<T> gains a 3rd state ignore (alongside ok / error) via enum class State
    • ignore stops downstream pipeline steps as a no-op — nothing is written to storage
    • error now passes through to downstream steps instead of being bypassed
    • New API: have_value(), is_ignored(), ignore() factory, propagate<U>()
  • ActionCtx gains nargs, value_index, total_values (replaces invoke_count)
    • nargs: number of values in this option occurrence
    • value_index: 0-based index of the current value within this occurrence
    • total_values: cumulative values across all occurrences
  • Action<>::invoke updated: bypasses on ignore, passes error through to each step
  • All built-in steps (conversion, validation, pack) updated to guard with have_value() and propagate error/ignore correctly
  • New conversion::DefaultMissingValue<V> step: accepts optional<string_view> as pipeline entry, injects compile-time default for flag-only invocations (nargs==0), returns ignore when a value invocation is expected
  • argument.hh: invoke_action / invoke_flag updated to pass nargs/value_index, and to use optional<string_view> entry when Action::entry_is_optional is true

🤖 Generated with Claude Code

gen740 and others added 4 commits May 11, 2026 14:41
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>

Copilot AI 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.

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 on ignore.
  • Extends ActionCtx with nargs, value_index, and total_values, and threads these through option/flag/positional invocation.
  • Adds conversion::DefaultMissingValue and updates built-in conversion/validation/pack steps to guard on have_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.

Comment thread include/cli/action.hh Outdated
Comment thread include/cli/action.hh
Comment thread include/cli/action.hh
gen740 added 7 commits May 11, 2026 16:33
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.

Copilot AI 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.

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated 2 comments.

Comment thread include/cli/argument.hh Outdated
Comment thread include/cli/parser.hh
@gen740
gen740 enabled auto-merge (rebase) May 11, 2026 14:16
@gen740
gen740 merged commit d2cb51f into main May 11, 2026
9 checks passed
@gen740
gen740 deleted the feat/action-result-ignore-state branch May 11, 2026 14:36
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.

2 participants