import config
import cognos11
from pdf import pdf_merge, pdf_test
import plac
from enum import Enum


class ExportFormat(Enum):
    PDF = "PDF"
    XML = "XML"


class C11:
    commands = ['export', 'reportoutput', 'errors', 'create']

    def __init__(self):
        self.cfg = config.Config()

    def export(self, folder='', format='XML'):
        exp = cognos11.c11_export(self.cfg)
        exp.export_folder(folder, format)

    def reportoutput(self, folder=''):
        exp = cognos11.c11_export(self.cfg)
        folder2 = exp.get_folder(folder)
        exp.export_folder(folder, 'PDF')
        pdf_test.missing_data(self.cfg.cognos11.reportoutput_dir + '/' + folder)
        pdf_merge.merge_reports_in_folder(self.cfg, folder2)

    def errors(self):
        exp = cognos11.c11_export(self.cfg)
        exp.export_errors()

    def create(self, path: str):
        cognos11.c11_create(self.cfg).create_path(path)


if __name__ == '__main__':
    plac.Interpreter.call(C11)
    # C11().reportoutput()
