intake/tests/demo_basic_callback/increment.py

20 lines
449 B
Python
Raw Normal View History

2023-06-01 03:50:56 +00:00
#!/usr/bin/env python3
import argparse, json, sys
parser = argparse.ArgumentParser()
parser.add_argument("action")
args = parser.parse_args()
print("args:", args, file=sys.stderr, flush=True)
if args.action == "fetch":
print(json.dumps({"id": "caller", "action": {"value": 1}}))
if args.action == "increment":
item = sys.stdin.readline()
item = json.loads(item)
item["action"]["value"] += 1
print(json.dumps(item))
pass