forked from sh-edraft.de/sh_linux_installation_scripts
Added application and collection service
This commit is contained in:
parent
c2fc611f94
commit
e017462416
7
src/multi_install/abc/application_service_abc.py
Normal file
7
src/multi_install/abc/application_service_abc.py
Normal file
@ -0,0 +1,7 @@
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
|
||||
class ApplicationServiceABC(ABC):
|
||||
|
||||
@abstractmethod
|
||||
def __init__(self): pass
|
7
src/multi_install/abc/collection_service_abc.py
Normal file
7
src/multi_install/abc/collection_service_abc.py
Normal file
@ -0,0 +1,7 @@
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
|
||||
class CollectionServiceABC(ABC):
|
||||
|
||||
@abstractmethod
|
||||
def __init__(self): pass
|
1
src/multi_install/model/__init__.py
Normal file
1
src/multi_install/model/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
# imports
|
4
src/multi_install/service/application_service.py
Normal file
4
src/multi_install/service/application_service.py
Normal file
@ -0,0 +1,4 @@
|
||||
class ApplicationService:
|
||||
|
||||
def __init__(self):
|
||||
pass
|
4
src/multi_install/service/collection_service.py
Normal file
4
src/multi_install/service/collection_service.py
Normal file
@ -0,0 +1,4 @@
|
||||
class CollectionService:
|
||||
|
||||
def __init__(self):
|
||||
pass
|
@ -4,6 +4,7 @@ from cpl_core.console import Console
|
||||
from cpl_query.extension import List
|
||||
from multi_install.abc.menu_service_abc import MenuServiceABC
|
||||
from multi_install.config.os_settings import OSSettings
|
||||
from multi_install.model.main_menu_enum import MainMenuEnum
|
||||
|
||||
|
||||
class MenuService(MenuServiceABC):
|
||||
@ -16,53 +17,75 @@ class MenuService(MenuServiceABC):
|
||||
def run(self):
|
||||
is_end = False
|
||||
while not is_end:
|
||||
self.select_os()
|
||||
main_menu = self.main_menu()
|
||||
is_end = self.select_os()
|
||||
if not is_end:
|
||||
is_end = self.main_menu()
|
||||
|
||||
if main_menu == 'Exit':
|
||||
is_end = True
|
||||
if is_end:
|
||||
Console.write_line()
|
||||
|
||||
elif main_menu == 'Back':
|
||||
break
|
||||
|
||||
def select_os(self):
|
||||
def select_os(self) -> bool:
|
||||
Console.clear()
|
||||
options = List(str, self._os_settings.operating_systems.copy())
|
||||
options.append('Exit')
|
||||
Console.write_line('Select option:')
|
||||
options.for_each(lambda o: Console.write_line(f'[{options.index(o)}] {o}'))
|
||||
os = int(Console.read('\n:'))
|
||||
options.for_each(lambda o: Console.write_line(f'[{options.index(o)+1}] {o}'))
|
||||
os = 0
|
||||
try:
|
||||
os = int(Console.read('\n:'))-1
|
||||
except ValueError:
|
||||
Console.error('Input value must be int!')
|
||||
return True
|
||||
|
||||
if os == options.index('Exit'):
|
||||
exit()
|
||||
return True
|
||||
|
||||
self._os = os
|
||||
return False
|
||||
|
||||
def main_menu(self) -> str:
|
||||
def main_menu(self) -> bool:
|
||||
Console.clear()
|
||||
options = List(str, [
|
||||
'Install collection',
|
||||
'Uninstall collection',
|
||||
'Add collection',
|
||||
'Remove collection',
|
||||
MainMenuEnum.install_collection.value,
|
||||
MainMenuEnum.uninstall_collection.value,
|
||||
MainMenuEnum.add_collection.value,
|
||||
MainMenuEnum.remove_collection.value,
|
||||
|
||||
'Install application',
|
||||
'Uninstall application',
|
||||
'Add application',
|
||||
'Remove application',
|
||||
'Add application',
|
||||
MainMenuEnum.install_application.value,
|
||||
MainMenuEnum.uninstall_application.value,
|
||||
MainMenuEnum.add_application.value,
|
||||
MainMenuEnum.remove_application.value,
|
||||
|
||||
'Back',
|
||||
'Exit'
|
||||
MainMenuEnum.back.value,
|
||||
MainMenuEnum.exit.value
|
||||
])
|
||||
Console.write_line('Select option:')
|
||||
options.for_each(lambda o: Console.write_line(f'[{options.index(o)}] {o}'))
|
||||
selected = int(Console.read('\n:'))
|
||||
if selected == options.index('Exit'):
|
||||
exit()
|
||||
options.for_each(lambda o: Console.write_line(f'[{options.index(o)+1}] {o}'))
|
||||
selected = 0
|
||||
try:
|
||||
selected = int(Console.read('\n:'))-1
|
||||
except ValueError:
|
||||
Console.error('Input value must be int!')
|
||||
return True
|
||||
|
||||
return selected
|
||||
# collection menu
|
||||
if 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
|
||||
|
||||
def select_collection(self) -> str:
|
||||
options = []
|
||||
options.append('Exit')
|
||||
return Console.select('>', 'Select collection:', options)
|
||||
# application menu
|
||||
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
|
||||
elif selected == options.index(MainMenuEnum.remove_application.value): pass
|
||||
|
||||
elif selected == options.index(MainMenuEnum.back.value):
|
||||
return
|
||||
elif selected == options.index(MainMenuEnum.exit.value):
|
||||
return True
|
||||
|
||||
else:
|
||||
raise Exception(f'Unknown option: {selected}')
|
||||
|
||||
return False
|
||||
|
Reference in New Issue
Block a user