def main(): console.print(f"Manim Community [green]v{__version__}[/green]") args = parse_args(sys.argv) if hasattr(args, "cmd"): if args.cmd == "cfg": if args.subcmd: from manim._config import cfg_subcmds if args.subcmd == "write": cfg_subcmds.write(args.level, args.open) elif args.subcmd == "show": cfg_subcmds.show() elif args.subcmd == "export": cfg_subcmds.export(args.dir) else: logger.error("No subcommand provided; Exiting...") elif args.cmd == "plugins": from manim.plugins import plugins_flags if args.list: plugins_flags.list_plugins() elif not args.list: logger.error("No flag provided; Exiting...") # elif args.cmd == "some_other_cmd": # something_else_here() else: config.digest_args(args) input_file = config.get_dir("input_file") if config["use_webgl_renderer"]: try: from manim.grpc.impl import frame_server_impl server = frame_server_impl.get(input_file) server.start() server.wait_for_termination() except ModuleNotFoundError as e: console.print( "Dependencies for the WebGL render are missing. Run " "pip install manim[webgl_renderer] to install them." ) console.print_exception() else: for SceneClass in scene_classes_from_file(input_file): try: scene = SceneClass() scene.render() open_file_if_needed(scene.renderer.file_writer) except Exception: console.print_exception()
def main(**args): class ClickArgs: def __init__(self, args): parser = get_streaming_configurations() exec("self.use_ipython = {}".format(parser["CLI"]["use_ipython"])) for name in args: setattr(self, name, args[name]) # self.scene_names = None def _get_kwargs(self): return list(self.__dict__.items()) def __eq__(self, other): if not isinstance(other, ClickArgs): return NotImplemented return vars(self) == vars(other) def __contains__(self, key): return key in self.__dict__ def __repr__(self): return str(self.__dict__) click_args = ClickArgs(args) config.digest_args(click_args) file = args["file"] if str(file) == "-": livestream(click_args.use_ipython) else: for SceneClass in scene_classes_from_file(file): try: scene = get_streamer(SceneClass) play_scene(scene) except Exception: console.print_exception()