cmdopt2/args: add ignore helper

This commit is contained in:
Danny Robson 2022-03-18 15:03:43 +10:00
parent 8a38459f9a
commit a63f4fef44
2 changed files with 25 additions and 0 deletions

View File

@ -22,6 +22,16 @@ positional::create (std::string &&name)
}
//-----------------------------------------------------------------------------
positional
positional::ignore (void) const
{
positional res = *this;
res.acceptor1.reset ();
return res;
}
///////////////////////////////////////////////////////////////////////////////
keyword
keyword::create (char const *name)
@ -105,4 +115,15 @@ 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;
}

View File

@ -84,6 +84,8 @@ namespace cruft::cmdopt2 {
static positional create (std::string const &name);
static positional create (std::string &&name);
positional ignore (void) const;
int count = 1;
};
@ -99,6 +101,8 @@ namespace cruft::cmdopt2 {
using ops::acceptor;
keyword acceptor (acceptor0_t);
keyword ignore (void) const;
keyword flag (void) const;
keyword flag (std::string_view long_) const;
keyword flag (char short_) const;