linux-tools/main.py

49 lines
1.1 KiB
Python
Raw Normal View History

from PyInquirer import prompt
2019-12-14 04:11:32 +01:00
import importlib
import os
def transform_list_into_choices(choices_list):
mapped_list = []
for choice in choices_list:
mapped_list.append({
"name": choice
})
return mapped_list
2019-12-14 04:26:02 +01:00
2019-12-14 04:11:32 +01:00
def load_modules():
print("Loading modules")
modules = {}
for folder in os.listdir("./modules"):
try:
curr_module = importlib.import_module('.' + folder, package="modules")
modules[folder] = curr_module.get_module()
except AttributeError:
pass
print("Modules loaded successfully.\n")
return modules
2019-12-14 04:11:32 +01:00
def open_module_selection(modules):
print("Available Modules:")
module_selection = [
{
'type': 'checkbox',
'message': 'Select modules',
'name': 'modules',
'choices': transform_list_into_choices(
list(modules.keys())
)
}
]
return prompt(module_selection)
2019-12-14 04:11:32 +01:00
modules = load_modules()
selected_modules = open_module_selection(modules)
for answer in selected_modules['modules']:
modules[answer].run()