cli20 0.1.2
A C++20 typed-schema command-line parser
Loading...
Searching...
No Matches
cli::Action< Fns > Struct Template Reference

A compile-time pipeline of action functions applied sequentially to a parsed token. More...

#include <action.hh>

Static Public Member Functions

template<class Arg, class Result>
static constexpr auto invoke (ActionCtx< Arg > &ctx, ActionResult< Result > input)
template<class Arg, class Result>
static constexpr auto invoke (const ActionCtx< Arg > &ctx, ActionResult< Result > input)
template<bool EnableTailCheck, class Prev, auto FnHead, auto... FnTail>
static constexpr auto validate_impl ()
static constexpr auto validate () -> auto

Static Public Attributes

static constexpr bool entry_is_optional

Detailed Description

template<auto... Fns>
requires (requires { { std::remove_cvref_t<decltype(Fns)>::template accepts_input<void> } -> std::convertible_to<bool>; typename std::remove_cvref_t<decltype(Fns)>::template storage_type<void>; } && ...)
struct cli::Action< Fns >

A compile-time pipeline of action functions applied sequentially to a parsed token.

Each element of Fns must be a constexpr-constructible callable that:

  • Exposes template<class I> static constexpr bool accepts_input — whether it can handle input of type I.
  • Exposes template<class I> using after_type — the output type when given input I.
  • Exposes template<class I> using storage_type — the argument storage type (non-void only for the last/terminal action in the pipeline).

Pipelines are composed with operator|:

constexpr auto my_action = cli::conversion::integer<int>
constexpr auto integer
Definition action.hh:921
constexpr auto set_once
Definition action.hh:1877
constexpr auto positive
Definition action.hh:1457

At pipeline invocation, ignore short-circuits the remaining steps while error is passed through so downstream steps can preserve or react to it.

Template Parameters
FnsPack of constexpr action objects forming the pipeline.

Definition at line 450 of file action.hh.

Member Function Documentation

◆ invoke() [1/2]

template<auto... Fns>
template<class Arg, class Result>
constexpr auto cli::Action< Fns >::invoke ( ActionCtx< Arg > & ctx,
ActionResult< Result > input )
inlinestaticnodiscardconstexpr

Definition at line 453 of file action.hh.

◆ invoke() [2/2]

template<auto... Fns>
template<class Arg, class Result>
constexpr auto cli::Action< Fns >::invoke ( const ActionCtx< Arg > & ctx,
ActionResult< Result > input )
inlinestaticnodiscardconstexpr

Definition at line 475 of file action.hh.

◆ validate()

template<auto... Fns>
constexpr auto cli::Action< Fns >::validate ( ) -> auto
inlinestaticconstexpr

Definition at line 535 of file action.hh.

◆ validate_impl()

template<auto... Fns>
template<bool EnableTailCheck, class Prev, auto FnHead, auto... FnTail>
constexpr auto cli::Action< Fns >::validate_impl ( )
inlinestaticconstexpr

Definition at line 497 of file action.hh.

Member Data Documentation

◆ entry_is_optional

template<auto... Fns>
bool cli::Action< Fns >::entry_is_optional
staticconstexpr
Initial value:
= FirstFnType<
Fns...>::type::template accepts_input<std::optional<std::string_view>>

Definition at line 532 of file action.hh.


The documentation for this struct was generated from the following file: