cmdopt2/args: add acceptor builder

This commit is contained in:
Danny Robson 2022-03-18 13:02:56 +10:00
parent 577d34eeb5
commit 1e1034711f
2 changed files with 21 additions and 0 deletions

View File

@ -96,3 +96,13 @@ keyword::present (bool &val) const
res.acceptor0 = [&val] (void) { val = true; }; res.acceptor0 = [&val] (void) { val = true; };
return res; return res;
} }
//-----------------------------------------------------------------------------
keyword
keyword::acceptor (acceptor0_t _acceptor)
{
keyword res = *this;
res.acceptor0 = _acceptor;
return res;
}

View File

@ -67,6 +67,14 @@ namespace cruft::cmdopt2 {
{ {
return reinterpret_cast<BaseT const&> (*this); return reinterpret_cast<BaseT const&> (*this);
} }
BaseT
acceptor (acceptor1_t _acceptor) const
{
BaseT res = get ();
res.acceptor1 = _acceptor;
return res;
}
}; };
@ -88,6 +96,9 @@ namespace cruft::cmdopt2 {
static keyword create (std::string const &name); static keyword create (std::string const &name);
static keyword create (std::string &&name); static keyword create (std::string &&name);
using ops::acceptor;
keyword acceptor (acceptor0_t);
keyword flag (void) const; keyword flag (void) const;
keyword flag (std::string_view long_) const; keyword flag (std::string_view long_) const;
keyword flag (char short_) const; keyword flag (char short_) const;