71 lines
1.7 KiB
Python
Executable File
71 lines
1.7 KiB
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)
|
|
|
|
def item(i):
|
|
print(json.dumps(i))
|
|
|
|
if args.action == "fetch":
|
|
item({
|
|
"id": "item1-only-id",
|
|
})
|
|
item({
|
|
"id": "item2-title",
|
|
"title": "This item has a title",
|
|
})
|
|
item({
|
|
"id": "item3-body",
|
|
"title": "This item has a title and body",
|
|
"body": "<p>Hello, intake! This is an <b>item</b> body.</p>",
|
|
})
|
|
item({
|
|
"id": "item4-action",
|
|
"title": "This item has an action but no body",
|
|
"action": {
|
|
"action1": None
|
|
},
|
|
})
|
|
item({
|
|
"id": "item5-actions",
|
|
"title": "This item has two actions and a body",
|
|
"body": "<p>This is body text.</p>",
|
|
"action": {
|
|
"action1": None,
|
|
"action2": None,
|
|
},
|
|
})
|
|
item({
|
|
"id": "item6-footer",
|
|
"title": "No body text but all footer fields",
|
|
"author": "Authorname",
|
|
"time": int(time.time()),
|
|
})
|
|
item({
|
|
"id": "item7-footer",
|
|
"title": "Body text and all footer fields",
|
|
"author": "Authorname",
|
|
"time": int(time.time()),
|
|
"body": "<p>This is body text.</p>",
|
|
})
|
|
item({
|
|
"id": "item8-link",
|
|
"title": "Item with a link",
|
|
"link": "#",
|
|
})
|
|
|
|
if args.action == "action1":
|
|
item = sys.stdin.readline()
|
|
item = json.loads(item)
|
|
print(json.dumps(item))
|
|
|
|
if args.action == "action2":
|
|
item = sys.stdin.readline()
|
|
item = json.loads(item)
|
|
print(json.dumps(item))
|