Source code for uetools.commands.plugin.disable

import json
from dataclasses import dataclass

from argklass.command import Command, newparser

from uetools.core.conf import find_project
from uetools.core.util import deduce_plugin, deduce_project


[docs] class Disable(Command): """Disable a plugin Examples -------- .. code-block:: console # Disable the plugin uecli disable --project TTSGame --plugin RTSGamePlugin """ name: str = "disable"
[docs] @dataclass class Arguments: project: str = deduce_project() # project's name plugin: str = deduce_plugin() # Plugin's name"
[docs] @staticmethod def arguments(subparsers): parser = newparser(subparsers, Disable) parser.add_argument( "--project", type=str, help="project's name", default=deduce_project() ) parser.add_argument("plugin", type=str, help="Plugin's name")
[docs] @staticmethod def execute(args): name = args.project uproject = find_project(args.project) with open(uproject, encoding="utf-8") as project_file: project_conf = json.load(project_file) plugins = project_conf.get("Plugins") plugin_dict = {} for plugin in plugins: name = plugin["Name"] data = plugin plugin_dict[name] = data if args.plugin in plugin_dict: plugin_dict[args.plugin]["Enabled"] = False else: plugins.append(dict(Name=args.plugin, Enabled=False)) with open(uproject, "w", encoding="utf-8") as project_file: json.dump(project_conf, project_file) return 0
COMMANDS = Disable