1
0
Fork 0

replaced interface logic

- replaced `inquirer` with `pytermgui`
This commit is contained in:
Kim, Jimin 2022-03-13 23:09:27 +09:00
parent 41dbd3c715
commit 3e4d43d4fd
5 changed files with 27 additions and 21 deletions

View file

@ -1,7 +1,10 @@
from .initialize import initialize
from .ui.show_main_menu import show_main_menu
def entry():
initialize()
show_main_menu()
# import should happen after the `initialize` function is called
from .interface.choose_action import choose_action
choose_action()

View file

@ -30,8 +30,8 @@ def initialize():
log.error("Failed to install PyYAML via pip")
exit(1)
# https://github.com/bczsalba/pytermgui
log.log("Initializing pytermgui")
if os.system("pip install pytermgui &> /dev/null"):
# https://github.com/magmax/python-inquirer
log.log("Initializing inquirer")
if os.system("pip install inquirer &> /dev/null"):
log.error("Failed to install pytermgui via pip")
exit(1)

View file

@ -0,0 +1,19 @@
import inquirer
from glob import glob
def choose_action():
files = glob("src/setup/**/*.py")
files = [s.removeprefix("src/setup/") for s in files if "__init__.py" not in s]
response = inquirer.prompt(
[
inquirer.Checkbox(
"actions",
message="What do you want to set up?",
choices=files,
),
]
)
print(response["actions"])

View file

@ -1,16 +0,0 @@
from argparse import ArgumentParser, Namespace
from subprocess import run
import pytermgui as ptg
def show_main_menu():
with ptg.WindowManager() as manager:
window = ptg.Window(
ptg.Label("[wm-title]menu"),
ptg.Label(),
ptg.Button("Exit!", lambda *_: manager.exit()),
)
manager.add(window)
manager.run()