#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; } /////////////////////////////////////////////////////////////////////////////// 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; }