#include "./args.hpp" using cruft::cmdopt2::positional; using cruft::cmdopt2::keyword; /////////////////////////////////////////////////////////////////////////////// positional positional::create (char const *name) { return create (std::string (name)); } //----------------------------------------------------------------------------- positional positional::create (std::string &&name) { positional res {}; res.name = name; return res; } //----------------------------------------------------------------------------- positional positional::ignore (void) const { positional res = *this; res.acceptor1.reset (); return res; } /////////////////////////////////////////////////////////////////////////////// keyword keyword::create (char const *name) { return create (std::string (name)); } //----------------------------------------------------------------------------- keyword keyword::create (std::string &&name) { keyword res {}; res.name = name; res.long_ = name; return res; } //----------------------------------------------------------------------------- keyword keyword::flag (void) const { keyword res = *this; res.long_.reset (); res.short_.reset (); return res; } //----------------------------------------------------------------------------- keyword keyword::flag (char val) const { keyword res = *this; res.short_ = val; return res; } //----------------------------------------------------------------------------- keyword keyword::flag (std::string_view val) const { keyword res = *this; res.long_ = val; return res; } //----------------------------------------------------------------------------- keyword keyword::count (int &val) const { CHECK (!acceptor1 and !acceptor0); keyword res = *this; res.acceptor0 = [&val] (void) { ++val; }; return res; } //----------------------------------------------------------------------------- keyword keyword::present (bool &val) const { CHECK (!acceptor1 and !acceptor0); val = false; keyword res = *this; res.acceptor0 = [&val] (void) { val = true; }; return res; } //----------------------------------------------------------------------------- keyword keyword::acceptor (acceptor0_t _acceptor) { keyword res = *this; res.acceptor0 = _acceptor; return res; } //----------------------------------------------------------------------------- keyword keyword::ignore (void) const { keyword res = *this; res.acceptor0.reset (); res.acceptor1.reset (); return res; }