From a63f4fef44db059a2f6d2a5f698eae02053ca664 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Fri, 18 Mar 2022 15:03:43 +1000 Subject: [PATCH] cmdopt2/args: add `ignore` helper --- cmdopt2/args.cpp | 21 +++++++++++++++++++++ cmdopt2/args.hpp | 4 ++++ 2 files changed, 25 insertions(+) diff --git a/cmdopt2/args.cpp b/cmdopt2/args.cpp index 5a1fdf6f..ac2de44f 100644 --- a/cmdopt2/args.cpp +++ b/cmdopt2/args.cpp @@ -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; } \ No newline at end of file diff --git a/cmdopt2/args.hpp b/cmdopt2/args.hpp index a642d106..758dfe2c 100644 --- a/cmdopt2/args.hpp +++ b/cmdopt2/args.hpp @@ -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;