forked from sh-edraft.de/sh_linux_installation_scripts
Compare commits
No commits in common. "e017462416c1babf70be9bedea78f341cd9b89a4" and "39cdd989f01365c59becde259aa551a02ada04cd" have entirely different histories.
e017462416
...
39cdd989f0
@ -1,7 +0,0 @@
|
|||||||
from abc import ABC, abstractmethod
|
|
||||||
|
|
||||||
|
|
||||||
class ApplicationServiceABC(ABC):
|
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def __init__(self): pass
|
|
@ -1,7 +0,0 @@
|
|||||||
from abc import ABC, abstractmethod
|
|
||||||
|
|
||||||
|
|
||||||
class CollectionServiceABC(ABC):
|
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def __init__(self): pass
|
|
@ -10,7 +10,10 @@ class MenuServiceABC(ABC):
|
|||||||
def run(self): pass
|
def run(self): pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def select_os(self) -> bool: pass
|
def select_os(self) -> str: pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def main_menu(self) -> bool: pass
|
def main_menu(self) -> str: pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def select_collection(self) -> str: pass
|
||||||
|
@ -1 +0,0 @@
|
|||||||
# imports
|
|
@ -1,17 +0,0 @@
|
|||||||
from enum import Enum
|
|
||||||
|
|
||||||
|
|
||||||
class MainMenuEnum(Enum):
|
|
||||||
|
|
||||||
install_collection = 'Install collection'
|
|
||||||
uninstall_collection = 'Uninstall collection'
|
|
||||||
add_collection = 'Add collection'
|
|
||||||
remove_collection = 'Remove collection'
|
|
||||||
|
|
||||||
install_application = 'Install application'
|
|
||||||
uninstall_application = 'Uninstall application'
|
|
||||||
add_application = 'Add application'
|
|
||||||
remove_application = 'Remove application'
|
|
||||||
|
|
||||||
back = 'Back'
|
|
||||||
exit = 'Exit'
|
|
@ -1,4 +0,0 @@
|
|||||||
class ApplicationService:
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
@ -1,4 +0,0 @@
|
|||||||
class CollectionService:
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
@ -4,7 +4,6 @@ from cpl_core.console import Console
|
|||||||
from cpl_query.extension import List
|
from cpl_query.extension import List
|
||||||
from multi_install.abc.menu_service_abc import MenuServiceABC
|
from multi_install.abc.menu_service_abc import MenuServiceABC
|
||||||
from multi_install.config.os_settings import OSSettings
|
from multi_install.config.os_settings import OSSettings
|
||||||
from multi_install.model.main_menu_enum import MainMenuEnum
|
|
||||||
|
|
||||||
|
|
||||||
class MenuService(MenuServiceABC):
|
class MenuService(MenuServiceABC):
|
||||||
@ -17,75 +16,53 @@ class MenuService(MenuServiceABC):
|
|||||||
def run(self):
|
def run(self):
|
||||||
is_end = False
|
is_end = False
|
||||||
while not is_end:
|
while not is_end:
|
||||||
is_end = self.select_os()
|
self.select_os()
|
||||||
if not is_end:
|
main_menu = self.main_menu()
|
||||||
is_end = self.main_menu()
|
|
||||||
|
if main_menu == 'Exit':
|
||||||
|
is_end = True
|
||||||
|
|
||||||
if is_end:
|
elif main_menu == 'Back':
|
||||||
Console.write_line()
|
break
|
||||||
|
|
||||||
def select_os(self) -> bool:
|
def select_os(self):
|
||||||
Console.clear()
|
Console.clear()
|
||||||
options = List(str, self._os_settings.operating_systems.copy())
|
options = List(str, self._os_settings.operating_systems.copy())
|
||||||
options.append('Exit')
|
options.append('Exit')
|
||||||
Console.write_line('Select option:')
|
Console.write_line('Select option:')
|
||||||
options.for_each(lambda o: Console.write_line(f'[{options.index(o)+1}] {o}'))
|
options.for_each(lambda o: Console.write_line(f'[{options.index(o)}] {o}'))
|
||||||
os = 0
|
os = int(Console.read('\n:'))
|
||||||
try:
|
|
||||||
os = int(Console.read('\n:'))-1
|
|
||||||
except ValueError:
|
|
||||||
Console.error('Input value must be int!')
|
|
||||||
return True
|
|
||||||
|
|
||||||
if os == options.index('Exit'):
|
if os == options.index('Exit'):
|
||||||
return True
|
exit()
|
||||||
|
|
||||||
self._os = os
|
self._os = os
|
||||||
return False
|
|
||||||
|
def main_menu(self) -> str:
|
||||||
def main_menu(self) -> bool:
|
|
||||||
Console.clear()
|
Console.clear()
|
||||||
options = List(str, [
|
options = List(str, [
|
||||||
MainMenuEnum.install_collection.value,
|
'Install collection',
|
||||||
MainMenuEnum.uninstall_collection.value,
|
'Uninstall collection',
|
||||||
MainMenuEnum.add_collection.value,
|
'Add collection',
|
||||||
MainMenuEnum.remove_collection.value,
|
'Remove collection',
|
||||||
|
|
||||||
MainMenuEnum.install_application.value,
|
'Install application',
|
||||||
MainMenuEnum.uninstall_application.value,
|
'Uninstall application',
|
||||||
MainMenuEnum.add_application.value,
|
'Add application',
|
||||||
MainMenuEnum.remove_application.value,
|
'Remove application',
|
||||||
|
'Add application',
|
||||||
|
|
||||||
MainMenuEnum.back.value,
|
'Back',
|
||||||
MainMenuEnum.exit.value
|
'Exit'
|
||||||
])
|
])
|
||||||
Console.write_line('Select option:')
|
Console.write_line('Select option:')
|
||||||
options.for_each(lambda o: Console.write_line(f'[{options.index(o)+1}] {o}'))
|
options.for_each(lambda o: Console.write_line(f'[{options.index(o)}] {o}'))
|
||||||
selected = 0
|
selected = int(Console.read('\n:'))
|
||||||
try:
|
if selected == options.index('Exit'):
|
||||||
selected = int(Console.read('\n:'))-1
|
exit()
|
||||||
except ValueError:
|
|
||||||
Console.error('Input value must be int!')
|
|
||||||
return True
|
|
||||||
|
|
||||||
# collection menu
|
return selected
|
||||||
if selected == options.index(MainMenuEnum.install_collection.value): pass
|
|
||||||
elif selected == options.index(MainMenuEnum.uninstall_collection.value): pass
|
def select_collection(self) -> str:
|
||||||
elif selected == options.index(MainMenuEnum.add_collection.value): pass
|
options = []
|
||||||
elif selected == options.index(MainMenuEnum.remove_collection.value): pass
|
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