Fix config editing

This commit is contained in:
Tim Van Baak 2023-06-02 17:09:51 -07:00
parent bd272c2e84
commit 70ee60bb65
3 changed files with 28 additions and 11 deletions

View File

@ -198,13 +198,12 @@ def try_parse_config(config_str: str):
fetch = action["fetch"]
if "exe" not in fetch:
return ("No fetch exe", {})
return (
None,
{
"action": parsed["action"],
"env": parsed["env"],
},
)
config = {
"action": parsed["action"]
}
if "env" in parsed:
config["env"] = parsed["env"]
return (None, config)
def wsgi():

View File

@ -13,7 +13,8 @@ if args.action == "fetch":
"id": "updateme",
"title": "The count is at 1",
"action": {
"increment": 1
"increment": 1,
"decrement": "",
}
}))
@ -24,4 +25,11 @@ if args.action == "increment":
item["body"] = f"<p>{item['action']['increment']}</p>"
item["title"] = f"The count is at {item['action']['increment']}"
print(json.dumps(item))
pass
if args.action == "decrement":
item = sys.stdin.readline()
item = json.loads(item)
item["action"]["increment"] -= 1
item["body"] = f"<p>{item['action']['increment']}</p>"
item["title"] = f"The count is at {item['action']['increment']}"
print(json.dumps(item))

View File

@ -2,11 +2,21 @@
"action": {
"fetch": {
"exe": "./increment.py",
"args": ["fetch"]
"args": [
"fetch"
]
},
"increment": {
"exe": "./increment.py",
"args": ["increment"]
"args": [
"increment"
]
},
"decrement": {
"exe": "./increment.py",
"args": [
"decrement"
]
}
}
}