2022-03-18 13:26:10 +11:00
|
|
|
#include "./args.hpp"
|
2022-03-16 14:20:26 +11:00
|
|
|
|
|
|
|
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;
|
2022-03-18 14:02:56 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
keyword
|
|
|
|
keyword::acceptor (acceptor0_t _acceptor)
|
|
|
|
{
|
|
|
|
keyword res = *this;
|
|
|
|
res.acceptor0 = _acceptor;
|
|
|
|
return res;
|
2022-03-16 14:20:26 +11:00
|
|
|
}
|