the start of something
This commit is contained in:
parent
51ed619e2f
commit
d8a73519d5
1 changed files with 30 additions and 0 deletions
30
python/src/lib/JsonCommunicator.py
Normal file
30
python/src/lib/JsonCommunicator.py
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#/usr/bin/env python
|
||||||
|
"""
|
||||||
|
veeeeeeeeeeeery early stage of something. Nothing commited yet.
|
||||||
|
propably will be converted to a class
|
||||||
|
"""
|
||||||
|
|
||||||
|
def ask(question: str, answer_list: list, default_option: str = ""):
|
||||||
|
"""
|
||||||
|
answer_list should contain:
|
||||||
|
[
|
||||||
|
{"short": "y", "long": "yes", "description": "helpful text"},
|
||||||
|
{"short": "n", "long": "no", "description": "helpful text"}
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
if default_option:
|
||||||
|
default_exists = False
|
||||||
|
for option in answer_list:
|
||||||
|
if default_option == option["short"] or default_option == option["long"]:
|
||||||
|
default_exists = True
|
||||||
|
if not default_exists:
|
||||||
|
raise NameError(f"default option: '{default_option}' not found in answer_list")
|
||||||
|
|
||||||
|
action = {
|
||||||
|
"type": question,
|
||||||
|
"content": {
|
||||||
|
"options": answer_list
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# send action
|
||||||
|
# return whatever response we got from the elisp stuff
|
Loading…
Add table
Reference in a new issue