2022-10-14 18:26:07 +00:00
|
|
|
import tty
|
|
|
|
import sys
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
def do_quit(): raise KeyboardInterrupt
|
|
|
|
|
|
|
|
def list_idens():
|
|
|
|
print('Listing identities')
|
|
|
|
|
|
|
|
|
|
|
|
main_menu = {
|
2022-10-17 20:45:45 +00:00
|
|
|
'l': (list_idens, 'list trusted identities'),
|
2022-10-14 18:26:07 +00:00
|
|
|
'q': (do_quit, 'quit CLI')
|
|
|
|
}
|
|
|
|
|
|
|
|
def main_ui():
|
|
|
|
tty.setraw(sys.stdin)
|
|
|
|
|
|
|
|
while True:
|
|
|
|
# move cursor to the beginning
|
|
|
|
print('\r', end='')
|
|
|
|
key = sys.stdin.read(1)
|
|
|
|
try:
|
|
|
|
main_menu[key][1]()
|
|
|
|
except KeyError:
|
|
|
|
pass
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
subprocess.Popen(['reset'], stdout=subprocess.PIPE)
|