Repository: ManimCommunity/manim
File: manim/_config/main_utils.py (Python)

Code before:
    """Parse CLI arguments.

    Parameters
    ----------
    args : :class:`list`
        A list of arguments; generally, this should be ``sys.argv``.

    Returns
    -------
    :class:`argparse.Namespace`
        An object returned by ``argparse.parse_args``.

    """
    if args[0] == "python" and args[1] == "-m":
        args = args[2:]

    if len(args) == 1:
        return _parse_args_no_subcmd(args)

    subcmd = _find_subcommand(args)
    if subcmd == "cfg":
        return _parse_args_cfg_subcmd(args)
    elif subcmd == "plugins":
        return _parse_args_plugins(args)
    elif args[1] == "--version":
        print(f"Manim Community v{ __version__ }")
        sys.exit()
    # elif subcmd == some_other_future_subcmd:
    #     return _parse_args_some_other_subcmd(args)
    elif subcmd is None:
        return _parse_args_no_subcmd(args)


def _parse_args_cfg_subcmd(args: list) -> argparse.Namespace:
    """Parse arguments of the form 'manim cfg <subcmd> <args>'."""
    parser = argparse.ArgumentParser(
        description="Animation engine for explanatory math videos",
        prog="manim cfg",
        epilog="Made with <3 by the ManimCommunity devs",
    )
    subparsers = parser.add_subparsers(help="subcommand", dest="subcmd")

    cfg_subparsers = {
        subcmd: subparsers.add_parser(subcmd) for subcmd in ["write", "show", "export"]
    }

    # Arguments for the write subcmd
    cfg_subparsers["write"].add_argument(
        "--level",
        choices=["user", "cwd"],
        default="cwd",

Review comment (suggestion):
 I think we should either not print out the version in `__main__.py`, or <strike>we should do a sys.exit() here.</strike> The sys.exit() is below the deleted line already.

Code after:
    """Parse CLI arguments.

    Parameters
    ----------
    args : :class:`list`
        A list of arguments; generally, this should be ``sys.argv``.

    Returns
    -------
    :class:`argparse.Namespace`
        An object returned by ``argparse.parse_args``.

    """
    if args[0] == "python" and args[1] == "-m":
        args = args[2:]

    if len(args) == 1:
        return _parse_args_no_subcmd(args)

    subcmd = _find_subcommand(args)
    if subcmd == "cfg":
        return _parse_args_cfg_subcmd(args)
    elif subcmd == "plugins":
        return _parse_args_plugins(args)
    elif args[1] == "--version":
        sys.exit()
    # elif subcmd == some_other_future_subcmd:
    #     return _parse_args_some_other_subcmd(args)
    elif subcmd is None:
        return _parse_args_no_subcmd(args)


def _parse_args_cfg_subcmd(args: list) -> argparse.Namespace:
    """Parse arguments of the form 'manim cfg <subcmd> <args>'."""
    parser = argparse.ArgumentParser(
        description="Animation engine for explanatory math videos",
        prog="manim cfg",
        epilog="Made with <3 by the ManimCommunity devs",
    )
    subparsers = parser.add_subparsers(help="subcommand", dest="subcmd")

    cfg_subparsers = {
        subcmd: subparsers.add_parser(subcmd) for subcmd in ["write", "show", "export"]
    }

    # Arguments for the write subcmd
    cfg_subparsers["write"].add_argument(
        "--level",
        choices=["user", "cwd"],
        default="cwd",
        help="Specify if this config is for user or the working directory.",