.. # split from OESystemFunctions.rst:2166

.. include:: ../substitutions

.. oe:namespace:: OESystem

.. meta::
   :keywords: OEParseCommandLineLW

.. oe:function:: OEParseCommandLineLW

   .. oe:language:: c++ java csharp

      .. oe:api::

         bool OEParseCommandLineLW(OEInterface& itf, int argc, char** argv,
                                   const unsigned char* requirements = NULL,
                                   unsigned int error_level = OEErrorLevel::Error)
         bool OEParseCommandLineLW(OEInterface& itf, const char* version,
                                   int argc, char** argv,
                                   const unsigned char* requirements = NULL,
                                   unsigned int error_level = OEErrorLevel::Error)

   .. oe:language:: python

      .. oe:api:: python

         OEParseCommandLineLW(itf: OEInterface, argc: int, argv: str,
                              requirements: str = None, error_level: int) -> bool
         OEParseCommandLineLW(itf: OEInterface, version: str, argc: int,
                              argv: str, requirements: str = None,
                              error_level: int) -> bool


   Set parameters in the 'itf'
   object by parsing the command line, 'argc' and 'argv'. This is the same
   purpose as :oe:func:`OESystem::OEParseCommandLine`, however, this function has different
   rules for parsing the command line, most notably nothing is entered as
   a key-value pair, and is in general designed for small lightweight
   interfaces, hence the *LW* in the function name.

   The ``version`` argument specifies what should be printed whenever
   the ``--version`` is found in ``argv``.

   When using this function all parameters of itf must fall into one
   of two categories.

   *  A boolean parameter with a default value of false and a name
      beginning with a dash followed by a single character.

   *  A keyless parameter (*i.e.* a parameter with a non-zero keyless
      value).

   and the command line should be of the following form.

   .. code-block:: bash

      program [boolean parameter keys] [keyless parameter values]

   **boolean parameter keys**

   Boolean parameters with keys listed listed in this part of the
   command line will be set to true (those not appearing will use
   their default value which must be ``false``). The characters of the
   boolean keys may also be combined into a single argument on the
   command line. This is easiest to illustrate in the following
   example:

   .. code-block:: bash

      program -a -b -c [keyless parameter values]

   and

   .. code-block:: bash

      program -abc [keyless parameter values]

   and

   .. code-block:: bash

      program -c -ba [keyless parameter values]

   Are all equivalent, provided '-a', '-b' and '-c' are boolean parameters
   with default values of ``false``.

   **keyless parameter values**

   The first argument not recognized as a boolean parameter will be
   assigned as the value of the parameter with a keyless value of ``1``,
   the second to the parameter with keyless value of ``2``, etc. If no
   parameter have the appropriate keyless value, or more than one have
   the required keyless value are error is reported, and the function
   returns ``false``.

   This function returns true if it was successful and ``false``
   otherwise. Errors are reported at 'error_level' to :oe:constns:`OESystem::OEThrow`.

