30 lines
729 B
Python
Executable File
30 lines
729 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import argparse, json, sys, time
|
|
|
|
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": str(int(time.time())),
|
|
"title": "Title has not been updated",
|
|
"action": {
|
|
"update": 0,
|
|
},
|
|
}
|
|
)
|
|
)
|
|
|
|
if args.action == "update" or args.action == "on_create":
|
|
item = sys.stdin.readline()
|
|
item = json.loads(item)
|
|
item["action"]["update"] += 1
|
|
item["title"] = f"Updated {item['action']['update']} times"
|
|
print(json.dumps(item))
|