main
====

.. py:module:: main

.. autoapi-nested-parse::

   Main program initialization.

   This package provides a class called Main used to initialize a python script
   invoked from command line. The main goal is to ensure consistency in terms of
   interface, documentation and logging activities for all scripts using e3.

   The script will support by default the following switches::

       -v|--verbose to enable verbose mode (a console logger is added)
       -h|--help    display command line help
       --log-file FILE
                    to redirect logs to a given file (this is independent of
                    verbose option)
       --console-logs
                    disable color, progress bars, and redirect as much as
                    possible to stdout, starting lines with the given prefix

   In addition, if the add_targets_options parameter is set to True
   when instantiating an object of class Main, the following switches
   will also be provided::

       --build      to set the build
       --host       to set the host
       --target     to set the target



Classes
-------

.. autoapisummary::

   main.Main


Module Contents
---------------

.. py:class:: Main(name: str | None = None, platform_args: bool = False, default_x86_64_on_windows: bool = False, argument_parser: argparse.ArgumentParser | None = None)

   Class that implement argument parsing.

   :ivar args: list of positional parameters after processing options


   .. py:attribute:: args
      :type:  argparse.Namespace | None
      :value: None



   .. py:attribute:: argument_parser
      :value: None



   .. py:attribute:: __log_handlers_set
      :value: False



   .. py:method:: parse_args(args: list[str] | None = None, known_args_only: bool = False, pre_platform_args_callback: collections.abc.Callable[[argparse.Namespace], None] | None = None) -> None

      Parse options and set console logger.

      :param args: the list of positional parameters. If None then
          ``sys.argv[1:]`` is used
      :param known_args_only: does not produce an error when extra
          arguments are present
      :param pre_platform_args_callback: function called after argument parsing
          but before applying the --build, --host and --target to env. The callback
          maybe use to adjust for example the default platform.



