Add command line interface with PyInquirer
Add update requirements.txt
This commit is contained in:
parent
c47b255924
commit
79449c8ad3
42
main.py
42
main.py
@ -1,7 +1,19 @@
|
|||||||
from CommandRunner import CommandRunnerDebug as Runner
|
from CommandRunner import CommandRunnerDebug as Runner
|
||||||
|
from PyInquirer import prompt
|
||||||
import importlib
|
import importlib
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
def transform_list_into_choices(choices_list):
|
||||||
|
mapped_list = []
|
||||||
|
for choice in choices_list:
|
||||||
|
mapped_list.append({
|
||||||
|
"name": choice
|
||||||
|
})
|
||||||
|
return mapped_list
|
||||||
|
|
||||||
|
|
||||||
|
def load_modules():
|
||||||
print("Loading modules")
|
print("Loading modules")
|
||||||
modules = {}
|
modules = {}
|
||||||
for folder in os.listdir("./modules"):
|
for folder in os.listdir("./modules"):
|
||||||
@ -11,21 +23,27 @@ for folder in os.listdir("./modules"):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
print("Modules loaded successfully.\n")
|
print("Modules loaded successfully.\n")
|
||||||
|
return modules
|
||||||
|
|
||||||
|
|
||||||
|
def open_module_selection(modules):
|
||||||
print("Available Modules:")
|
print("Available Modules:")
|
||||||
for mod in modules.keys():
|
module_selection = [
|
||||||
print(mod)
|
{
|
||||||
|
'type': 'checkbox',
|
||||||
|
'message': 'Select modules',
|
||||||
|
'name': 'modules',
|
||||||
|
'choices': transform_list_into_choices(
|
||||||
|
list(modules.keys())
|
||||||
|
)
|
||||||
|
}
|
||||||
|
]
|
||||||
|
return prompt(module_selection)
|
||||||
|
|
||||||
print()
|
|
||||||
|
|
||||||
while True:
|
modules = load_modules()
|
||||||
chosen_module = input("Please specify your module: ")
|
|
||||||
if chosen_module in modules.keys():
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
print("Module was not found.")
|
|
||||||
|
|
||||||
print("\nChosen Module to run: " + chosen_module)
|
selected_modules = open_module_selection(modules)
|
||||||
|
|
||||||
Runner().run(modules[chosen_module])
|
|
||||||
|
|
||||||
|
for answer in selected_modules['modules']:
|
||||||
|
Runner().run(modules[answer])
|
||||||
|
@ -1 +1 @@
|
|||||||
|
PyInquirer==1.0.3
|
||||||
|
Loading…
Reference in New Issue
Block a user