main

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 term 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 from
             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

Module Contents

Classes

Main

Class that implement argument parsing.

class main.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.

Variables:

args – list of positional parameters after processing options

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.

Parameters:
  • args – the list of positional parameters. If None then sys.argv[1:] is used

  • known_args_only – does not produce an error when extra arguments are present

  • 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.