41 lines
977 B
Python
41 lines
977 B
Python
from src.parser import get_args
|
|
from src.node_manager import NodeManager
|
|
|
|
actions = [
|
|
{'explanation': 'Add another node into our cluster', 'function': 'add_node'},
|
|
{'explanation': 'Exit', 'function': 'exit'},
|
|
]
|
|
|
|
if __name__ == '__main__':
|
|
args = get_args()
|
|
host, port = args.host, args.port
|
|
|
|
manager = NodeManager(host, port)
|
|
manager.start_service()
|
|
|
|
|
|
while True:
|
|
explanation = '=' * 30 + '\n'
|
|
for index, action in enumerate(actions):
|
|
explanation += f'{index+1}) {action["explanation"]}\n'
|
|
explanation += '=' * 30
|
|
explanation += '\n> '
|
|
|
|
action = input(explanation)
|
|
|
|
try:
|
|
action = actions[int(action)-1]
|
|
if action['function'] == 'exit':
|
|
break
|
|
else:
|
|
func = getattr(manager, action['function'])
|
|
func()
|
|
except:
|
|
None
|
|
|
|
print("\n\n\n")
|
|
print("Stopped")
|
|
|
|
|
|
|