From 5732b9e64cb1d47222cec3e99103947e2a8ce8d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20D=C3=A9al?= Date: Mon, 11 Mar 2019 19:09:40 +0100 Subject: [PATCH] Add the positionnal option to make parser stop on first unknown option --- SimpleOpt.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/SimpleOpt.h b/SimpleOpt.h index bd2da41..61483a4 100644 --- a/SimpleOpt.h +++ b/SimpleOpt.h @@ -267,7 +267,10 @@ enum _ESOFlags SO_O_ICASE_WORD = 0x0400, /*! Case-insensitive comparisons for all arg types */ - SO_O_ICASE = 0x0700 + SO_O_ICASE = 0x0700, + + /*! Set the parser stop at first unvalid option*/ + SO_O_POSITIONAL = 0x0800 }; /*! Types of arguments that options may have. Note that some of the _ESOFlags @@ -679,6 +682,11 @@ CSimpleOptTempl::Next() // and we are not suppressing errors for invalid options then it // is reported as an error, otherwise it is data. if (nTableIdx < 0) { + if (HasFlag(SO_O_POSITIONAL)) { + Stop(); + return false; + } + if (!HasFlag(SO_O_NOERR) && pszArg[0] == (SOCHAR)'-') { m_pszOptionText = pszArg; break;