-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrespyte.py
executable file
·51 lines (47 loc) · 1.52 KB
/
respyte.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python3
"""Postman like TUI"""
from os import path
import sys
import configargparse
from asciimatics.scene import Scene
from asciimatics.screen import Screen
from asciimatics.exceptions import ResizeScreenError
from librespyte.rest import RestView
from librespyte.history import HistoryView
def parse():
"""adds and parses arguments"""
data = ".respyterc"
default = path.join(path.expanduser("~"), data + ".yml")
parser = configargparse.ArgParser(
config_file_parser_class=configargparse.YAMLConfigFileParser,
default_config_files=[default])
parser.add(
'-c', '--color-scheme',
default="bright",
help='color scheme to use [monochrome, green, bright, tlj256, blue] defaults to bright'
)
return parser.parse_args()
def respyte_tui(screen, scene, parsed_args):
"""start playing tui scenes"""
scenes = [
Scene([
RestView(screen, parsed_args)
], -1, name="Main"),
Scene([
HistoryView(screen, parsed_args)
], -1, name="History"),
]
screen.play(scenes, stop_on_resize=True, start_scene=scene, allow_int=True)
def main():
"""injection point from terminal"""
parsed_args = parse()
last_scene = None
while True:
try:
Screen.wrapper(respyte_tui, catch_interrupt=True, arguments=[last_scene, parsed_args])
sys.exit(0)
except ResizeScreenError as err:
last_scene = err.scene
if __name__ == "__main__":
sys.path.append('.')
main()