# Path: jirafs/utils.py
# def convert_to_boolean(string):
# def stash_local_changes(repo):
# def get_user_input(message, options=None, boolean=False, password=False):
# def run_command_method_with_kwargs(command, method=None, **kwargs):
# def get_installed_commands():
# def get_installed_plugins(subclass=Plugin):
# def get_config_path(filename):
# def get_config(additional_configs=None, include_global=True):
# def set_global_config_value(section, key, value):
# def get_default_jira_server(config=None):
# def get_jira(domain=None, config=None):
#     def get_section(config, domain):
# def get_git_version():
# def lazy_get_jira():
# def format_date(folder, date):
# def find_files_referenced_in_markup(markup: str) -> Dict[str, Tuple[str, int, int]]:
# def get_comment_author_display(comment: Comment) -> Optional[str]:
# 
# Path: jirafs/plugin.py
# class CommandPlugin(JirafsPluginBase):
#     def __init__(self, **kwargs):
#         for k, v in kwargs.items():
#             setattr(self, k, v)
# 
#     def truncate_field_value(self, original_value, length=30):
#         if original_value is None:
#             original_value = ""
#         elif not isinstance(original_value, str):
#             original_value = str(original_value)
#         value = original_value.strip()
#         for newline in ("\n", "\r"):
#             if newline in value:
#                 value = value[0 : value.find(newline)]
# 
#         value = value[0:length]
# 
#         if value != original_value:
#             value = value[0 : length - 1] + "\u2026"
# 
#         return value
# 
#     def get_description(self):
#         try:
#             return self.__doc__.strip()
#         except AttributeError:
#             raise None
# 
#     def add_arguments(self, parser):
#         pass
# 
#     def parse_arguments(self, parser, extra_args):
#         return parser.parse_args(extra_args)
# 
#     @classmethod
#     def get_command_result(cls, result, original=None):
#         if not isinstance(result, CommandResult):
#             result = CommandResult(result)
# 
#         if original is not None:
#             result = original + result
# 
#         return result
# 
#     @classmethod
#     def execute_command(cls, extra_args, jira, path, command_name, **ckwargs):
#         from .ticketfolder import TicketFolder
# 
#         cmd = cls(entrypoint_name=command_name)
# 
#         parser = argparse.ArgumentParser(
#             prog=os.path.basename(sys.argv[0]) + " " + command_name,
#             description=cmd.get_description(),
#         )
#         if cmd.auto_instantiate_folder():
#             parser.add_argument(
#                 "--no-migrate", dest="migrate", default=True, action="store_false"
#             )
#         cmd.add_arguments(parser)
#         args = cmd.parse_arguments(parser, extra_args)
# 
#         folder = None
#         folder_plugins = []
#         if cmd.auto_instantiate_folder():
#             folder = TicketFolder(path, jira, migrate=args.migrate)
#             folder_plugins = folder.plugins
# 
#         kwargs = {
#             "args": args,
#             "folder": folder,
#             "jira": jira,
#             "path": path,
#             "parser": parser,
#         }
#         pre_method = "pre_%s" % command_name
#         post_method = "post_%s" % command_name
#         for plugin in folder_plugins:
#             if not hasattr(plugin, pre_method):
#                 continue
#             method = getattr(plugin, pre_method)
#             result = method(**kwargs)
#             if result is not None:
#                 kwargs = result
# 
#         cmd.validate(**kwargs)
#         result = cls.get_command_result(cmd.handle(**kwargs))
# 
#         for plugin in folder_plugins:
#             if not hasattr(plugin, post_method):
#                 continue
#             method = getattr(plugin, post_method)
#             post_result = method(result)
#             if post_result is not None:
#                 result = cls.get_command_result(post_result, original=result)
# 
#         if getattr(cls, "RUN_FOR_SUBTASKS", False):
#             for subfolder in folder.subtasks:
#                 try:
#                     cls.execute_command(
#                         extra_args, jira, subfolder.path, command_name, **ckwargs
#                     )
#                 except Exception as e:
#                     logger.exception(
#                         "Exception encountered while running "
#                         "'%s' for ticket subfolder '%s': %s"
#                         % (command_name, subfolder.ticket_number, e)
#                     )
# 
#         return result
# 
#     def handle(self, *args, **kwargs) -> None:
#         return self.cmd(*args, **kwargs)
# 
#     def cmd(self, *args, **kwargs) -> None:
#         # By default, no return value; just execute and move along
#         self.main(*args, **kwargs)
# 
#     def main(self, *args, **kwargs) -> None:
#         raise NotImplementedError()
# 
#     def try_subfolders(self) -> bool:
#         return getattr(self, "TRY_SUBFOLDERS", False)
# 
#     def auto_instantiate_folder(self) -> bool:
#         return getattr(
#             self,
#             "AUTOMATICALLY_INSTANTIATE_FOLDER",
#             True,
#         )


from blessings import Terminal
from jirafs import utils
from jirafs.plugin import CommandPlugin
        )
        parser.add_argument(
            "--global",
            dest="set_global",
            default=False,
            action="store_true",
        )

    def build_plugin_dict(self, enabled, available):
        all_plugins = {}
        for entrypoint_name, cls in available.items():
            all_plugins[entrypoint_name] = {
                "enabled": False,
                "class": cls,
            }
        for plugin_instance in enabled:
            entrypoint_name = plugin_instance.entrypoint_name
            all_plugins[entrypoint_name]["enabled"] = True
            all_plugins[entrypoint_name]["instance"] = plugin_instance

        return all_plugins

    def main(self, folder, args):
        t = Terminal()

        enabled_plugins = folder.load_plugins()
        available_plugins = utils.get_installed_plugins()

        if args.enable:
            if args.set_global:

# Path: jirafs/utils.py
# def convert_to_boolean(string):
# def stash_local_changes(repo):
# def get_user_input(message, options=None, boolean=False, password=False):
# def run_command_method_with_kwargs(command, method=None, **kwargs):
# def get_installed_commands():
# def get_installed_plugins(subclass=Plugin):
# def get_config_path(filename):
# def get_config(additional_configs=None, include_global=True):
# def set_global_config_value(section, key, value):
# def get_default_jira_server(config=None):
# def get_jira(domain=None, config=None):
#     def get_section(config, domain):
# def get_git_version():
# def lazy_get_jira():
# def format_date(folder, date):
# def find_files_referenced_in_markup(markup: str) -> Dict[str, Tuple[str, int, int]]:
# def get_comment_author_display(comment: Comment) -> Optional[str]:
# 
# Path: jirafs/plugin.py
# class CommandPlugin(JirafsPluginBase):
#     def __init__(self, **kwargs):
#         for k, v in kwargs.items():
#             setattr(self, k, v)
# 
#     def truncate_field_value(self, original_value, length=30):
#         if original_value is None:
#             original_value = ""
#         elif not isinstance(original_value, str):
#             original_value = str(original_value)
#         value = original_value.strip()
#         for newline in ("\n", "\r"):
#             if newline in value:
#                 value = value[0 : value.find(newline)]
# 
#         value = value[0:length]
# 
#         if value != original_value:
#             value = value[0 : length - 1] + "\u2026"
# 
#         return value
# 
#     def get_description(self):
#         try:
#             return self.__doc__.strip()
#         except AttributeError:
#             raise None
# 
#     def add_arguments(self, parser):
#         pass
# 
#     def parse_arguments(self, parser, extra_args):
#         return parser.parse_args(extra_args)
# 
#     @classmethod
#     def get_command_result(cls, result, original=None):
#         if not isinstance(result, CommandResult):
#             result = CommandResult(result)
# 
#         if original is not None:
#             result = original + result
# 
#         return result
# 
#     @classmethod
#     def execute_command(cls, extra_args, jira, path, command_name, **ckwargs):
#         from .ticketfolder import TicketFolder
# 
#         cmd = cls(entrypoint_name=command_name)
# 
#         parser = argparse.ArgumentParser(
#             prog=os.path.basename(sys.argv[0]) + " " + command_name,
#             description=cmd.get_description(),
#         )
#         if cmd.auto_instantiate_folder():
#             parser.add_argument(
#                 "--no-migrate", dest="migrate", default=True, action="store_false"
#             )
#         cmd.add_arguments(parser)
#         args = cmd.parse_arguments(parser, extra_args)
# 
#         folder = None
#         folder_plugins = []
#         if cmd.auto_instantiate_folder():
#             folder = TicketFolder(path, jira, migrate=args.migrate)
#             folder_plugins = folder.plugins
# 
#         kwargs = {
#             "args": args,
#             "folder": folder,
#             "jira": jira,
#             "path": path,
#             "parser": parser,
#         }
#         pre_method = "pre_%s" % command_name
#         post_method = "post_%s" % command_name
#         for plugin in folder_plugins:
#             if not hasattr(plugin, pre_method):
#                 continue
#             method = getattr(plugin, pre_method)
#             result = method(**kwargs)
#             if result is not None:
#                 kwargs = result
# 
#         cmd.validate(**kwargs)
#         result = cls.get_command_result(cmd.handle(**kwargs))
# 
#         for plugin in folder_plugins:
#             if not hasattr(plugin, post_method):
#                 continue
#             method = getattr(plugin, post_method)
#             post_result = method(result)
#             if post_result is not None:
#                 result = cls.get_command_result(post_result, original=result)
# 
#         if getattr(cls, "RUN_FOR_SUBTASKS", False):
#             for subfolder in folder.subtasks:
#                 try:
#                     cls.execute_command(
#                         extra_args, jira, subfolder.path, command_name, **ckwargs
#                     )
#                 except Exception as e:
#                     logger.exception(
#                         "Exception encountered while running "
#                         "'%s' for ticket subfolder '%s': %s"
#                         % (command_name, subfolder.ticket_number, e)
#                     )
# 
#         return result
# 
#     def handle(self, *args, **kwargs) -> None:
#         return self.cmd(*args, **kwargs)
# 
#     def cmd(self, *args, **kwargs) -> None:
#         # By default, no return value; just execute and move along
#         self.main(*args, **kwargs)
# 
#     def main(self, *args, **kwargs) -> None:
#         raise NotImplementedError()
# 
#     def try_subfolders(self) -> bool:
#         return getattr(self, "TRY_SUBFOLDERS", False)
# 
#     def auto_instantiate_folder(self) -> bool:
#         return getattr(
#             self,
#             "AUTOMATICALLY_INSTANTIATE_FOLDER",
#             True,
#         )


# Path: jirafs/commands/plugins.py
from blessings import Terminal
from jirafs import utils
from jirafs.plugin import CommandPlugin

        )
        parser.add_argument(
            "--global",
            dest="set_global",
            default=False,
            action="store_true",
        )

    def build_plugin_dict(self, enabled, available):
        all_plugins = {}
        for entrypoint_name, cls in available.items():
            all_plugins[entrypoint_name] = {
                "enabled": False,
                "class": cls,
            }
        for plugin_instance in enabled:
            entrypoint_name = plugin_instance.entrypoint_name
            all_plugins[entrypoint_name]["enabled"] = True
            all_plugins[entrypoint_name]["instance"] = plugin_instance

        return all_plugins

    def main(self, folder, args):
        t = Terminal()

        enabled_plugins = folder.load_plugins()
        available_plugins = utils.get_installed_plugins()

        if args.enable:
            if args.set_global:

                utils.set_global_config_value(