diff --git a/src/multi_install/config/application_list_settings.py b/src/multi_install/config/application_list_settings.py new file mode 100644 index 0000000..3b1ec71 --- /dev/null +++ b/src/multi_install/config/application_list_settings.py @@ -0,0 +1,39 @@ +import traceback + +from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC +from cpl_core.console import Console + +from multi_install.config.application_settings import ApplicationSettings + + +class ApplicationListSettings(ConfigurationModelABC): + + def __init__(self): + ConfigurationModelABC.__init__(self) + + self._debian_apps = [] + self._red_hat_apps = [] + + @property + def debian_apps(self) -> str: + return self._debian_apps + + @property + def redhat_apps(self) -> str: + return self._debian_apps + + def from_dict(self, settings: dict): + try: + + for app_cfg in settings['Debian']: + app = ApplicationSettings() + app.from_dict(app_cfg) + self._debian_apps.append(app) + + for app_cfg in settings['RedHat']: + app = ApplicationSettings() + app.from_dict(app_cfg) + self._red_hat_apps.append(app) + except Exception as e: + Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {self.__name__} settings') + Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}') diff --git a/src/multi_install/config/application_settings.py b/src/multi_install/config/application_settings.py new file mode 100644 index 0000000..0546bf2 --- /dev/null +++ b/src/multi_install/config/application_settings.py @@ -0,0 +1,36 @@ +import traceback +from typing import Optional + +from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC +from cpl_core.console import Console + + +class ApplicationSettings(ConfigurationModelABC): + + def __init__(self): + ConfigurationModelABC.__init__(self) + + self._name = '' + self._repository = '' + self._source_url = '' + + @property + def name(self) -> str: + return self._name + + @property + def repository(self) -> str: + return self._repository + + @property + def source_url(self) -> Optional[str]: + return self._source_url(self) + + def from_dict(self, settings: dict): + try: + self._name = settings['Name'] + self._repository = settings['Repository'] if 'Repository' in settings else None + self._source_url = settings['SourceUrl'] if 'SourceUrl' in settings else None + except Exception as e: + Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {self.__name__} settings') + Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}') diff --git a/src/multi_install/model/main_menu_enum.py b/src/multi_install/model/main_menu_enum.py index 4aaee8b..3222959 100644 --- a/src/multi_install/model/main_menu_enum.py +++ b/src/multi_install/model/main_menu_enum.py @@ -3,11 +3,13 @@ from enum import Enum class MainMenuEnum(Enum): + list_collection = 'List collection' install_collection = 'Install collection' uninstall_collection = 'Uninstall collection' add_collection = 'Add collection' remove_collection = 'Remove collection' + list_application = 'List application' install_application = 'Install application' uninstall_application = 'Uninstall application' add_application = 'Add application' diff --git a/src/multi_install/service/application_menu_service.py b/src/multi_install/service/application_menu_service.py index 11eca42..736f0b8 100644 --- a/src/multi_install/service/application_menu_service.py +++ b/src/multi_install/service/application_menu_service.py @@ -1,9 +1,10 @@ from multi_install.abc.application_menu_service_abc import ApplicationMenuServiceABC +from multi_install.config.application_list_settings import ApplicationListSettings class ApplicationMenuService(ApplicationMenuServiceABC): - def __init__(self): + def __init__(self, application_settings: ApplicationListSettings): pass def install_application(self): pass diff --git a/src/multi_install/service/menu_service.py b/src/multi_install/service/menu_service.py index e50d9db..f95c6fc 100644 --- a/src/multi_install/service/menu_service.py +++ b/src/multi_install/service/menu_service.py @@ -69,12 +69,14 @@ class MenuService(MenuServiceABC): return True # collection menu - if selected == options.index(MainMenuEnum.install_collection.value): pass + if selected == options.index(MainMenuEnum.list_collection.value): pass + elif selected == options.index(MainMenuEnum.install_collection.value): pass elif selected == options.index(MainMenuEnum.uninstall_collection.value): pass elif selected == options.index(MainMenuEnum.add_collection.value): pass elif selected == options.index(MainMenuEnum.remove_collection.value): pass # application menu + elif selected == options.index(MainMenuEnum.list_application.value): pass elif selected == options.index(MainMenuEnum.install_application.value): pass elif selected == options.index(MainMenuEnum.uninstall_application.value): pass elif selected == options.index(MainMenuEnum.add_application.value): pass diff --git a/src/multi_install_cli/apps.json b/src/multi_install_cli/apps.json new file mode 100644 index 0000000..d441498 --- /dev/null +++ b/src/multi_install_cli/apps.json @@ -0,0 +1,98 @@ +{ + "Application": { + "RedHat": [], + "Debian": [ + { + "Name": "brave-browser", + "Deps": [ + { + "Name": "apt-transport-https" + }, + { + "Name": "curl" + } + ] + }, + { + "Name": "barrier" + }, + { + "Name": "gnome-boxes" + }, + { + "Name": "google-chrome", + "SourceUrl": "https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb" + }, + { + "Name": "chrome-gnome-shell" + }, + { + "Name": "discord", + "SourceUrl": "https://discordapp.com/api/download?platform=linux&format=deb" + }, + { + "Name:": "balena-etcher-electron" + }, + { + "Name": "flameshot" + }, + { + "Name": "geary" + }, + { + "Name": "git" + }, + { + "Name": "gnome-tweaks" + }, + { + "Name": "gpick" + }, + { + "Name": "kcolorchooser" + }, + { + "Name": "keepassxc" + }, + { + "Name": "lsd", + "SourceUrl": "https://github.com/Peltoche/lsd/releases/download/0.19.0/lsd_0.19.0_amd64.deb" + }, + { + "Name": "ncdu" + }, + { + "Name": "neofetch" + }, + { + "Name": "nextcloud-client", + "Repository": "ppa:nextcloud-devs/client" + }, + { + "Name": "signal-desktop" + }, + { + "Name": "stacer" + }, + { + "Name": "sublime-text", + "Repository": "deb https://download.sublimetext.com/ apt/stable/" + }, + { + "Name": "timeshift", + "Repository": "ppa:teejee2008/ppa" + }, + { + "Name": "trash-cli" + }, + { + "Name": "ulauncher", + "Repository": "ppa:agornostal/ulauncher" + }, + { + "Name": "code", + "Repository": "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" + } + ] + } +} \ No newline at end of file