Skip to content

[codex] Add custom action helpers and examples - #35

Merged
gen740 merged 5 commits into
mainfrom
refactor/action-result-helpers
May 11, 2026
Merged

gen740 merged 5 commits into
mainfrom
refactor/action-result-helpers

Conversation

@gen740

@gen740 gen740 commented May 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add cli::action::custom for one-off non-terminal action pipeline steps.
  • Tighten pack::callback with a CallbackInvocable concept.
  • Update the advanced example to use action::custom and add a full struct-based custom action example.
  • Add a git-style command example inspired by clap's git.rs.
  • Expand Actions & Pipelines docs and example pages for custom actions and git-style subcommands.

Validation

  • nix run .#build
  • ctest --test-dir build --output-on-failure

@gen740
gen740 marked this pull request as ready for review May 11, 2026 16:28

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 expands cli20’s action pipeline capabilities by introducing cli::action::custom<fn> for inline/non-terminal pipeline steps, tightening callback action constraints, and improving Windows Unicode handling by moving UTF-16→UTF-8 conversion outside the parser. It also adds new example programs and documentation updates to demonstrate custom actions and git-style subcommands.

Changes:

  • Add cli::action::custom<fn> and improve action validation/type deduction helpers in include/cli/action.hh.
  • Introduce cli::utf16_to_utf8(argc, argv) and remove Windows wchar_t* argv parsing overloads in favor of explicit conversion.
  • Add/refresh examples and docs: new git and custom_action examples plus expanded docs for defining custom pipeline steps.

Reviewed changes

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

Show a summary per file
File Description
TODO.md Marks validation/action-type work as completed; adds note for nargs::rest.
tests/test_parse.cc Updates tests to use action::custom and explicit UTF-16→UTF-8 conversion for Windows-wide argv tests.
include/cli/parser.hh Adds Utf8Argv + utf16_to_utf8; removes wchar_t* parse overloads and updates Windows guidance.
include/cli/argument.hh Updates action validation type extraction to match tuple-based Action::validate() return.
include/cli/action.hh Adds ok/fail/ignore helpers, strengthens action validation, introduces action::custom, and tightens pack::callback via a concept.
examples/unicode_echo.cc Uses explicit UTF-16→UTF-8 conversion in wmain before calling UTF-8 parser path.
examples/git.cc Adds a git-style, command-heavy example with nested subcommands.
examples/custom_action.cc Adds a reusable struct-based custom conversion example.
examples/advanced.cc Updates advanced example to use cli::action::custom<fn>.
docs/docs/tutorial.md Links to custom pipeline step docs.
docs/docs/examples/index.mdx Adds entries for Custom Action + Git examples and renumbers sidebar ordering.
docs/docs/examples/git.mdx New documentation page for the git example.
docs/docs/examples/env-fallback.mdx Renumbers sidebar position/title to account for new examples.
docs/docs/examples/distribution-and-platform.mdx Renumbers sidebar position/title to account for new examples.
docs/docs/examples/custom-action.mdx New documentation page for the custom action example.
docs/docs/examples/compiler.mdx Renumbers sidebar position/title to account for new examples.
docs/docs/examples/advanced.mdx Mentions action::custom and links to Custom Action example.
docs/docs/actions.mdx Expands guidance and adds a concrete action::custom example for custom pipeline steps.

💡 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 Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@gen740
gen740 enabled auto-merge (rebase) May 11, 2026 16:50
@gen740
gen740 merged commit 64399de into main May 11, 2026
9 checks passed
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