HEX
Server: Apache
System: Linux server.enlacediseno.com 4.18.0-553.62.1.el8_10.x86_64 #1 SMP Wed Jul 16 04:08:25 EDT 2025 x86_64
User: maor (1069)
PHP: 7.3.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/relenv/__main__.py
# Copyright 2023-2025 Broadcom.
# SPDX-License-Identifier: Apache-2
"""
The entrypoint into relenv.
"""

from argparse import ArgumentParser

from . import build, buildenv, check, create, fetch, pyversions, toolchain
from .common import __version__


def setup_cli():
    """
    Build the argparser with its subparsers.

    The modules with commands to add must specify a setup_parser function
    that takes in the subparsers object from `argparse.add_subparsers()`

    :return: The fully setup argument parser
    :rtype: ``argparse.ArgumentParser``
    """
    argparser = ArgumentParser(
        prog="relenv",
        description="Relenv",
    )
    argparser.add_argument("--version", action="version", version=__version__)
    subparsers = argparser.add_subparsers()

    modules_to_setup = [
        build,
        toolchain,
        create,
        fetch,
        check,
        buildenv,
        pyversions,
    ]
    for mod in modules_to_setup:
        mod.setup_parser(subparsers)

    return argparser


def main():
    """
    Run the relenv cli and disbatch to subcommands.
    """
    parser = setup_cli()
    args = parser.parse_args()
    if hasattr(args, "func"):
        args.func(args)
    else:
        parser.print_help()
        parser.exit(1, "\nNo subcommand given...\n\n")


if __name__ == "__main__":
    main()