change arguments

This commit is contained in:
nebula 2025-04-21 06:18:31 +00:00
parent 654c2b8307
commit 6d0fafdd00
2 changed files with 22 additions and 20 deletions

View File

@ -16,11 +16,13 @@ buttons used to navigate the list are similar to `less`. here are the keys you c
* g: go to top
* G: go to bottom
`~nebula/bink --help`: returns a link to this page
`~nebula/bink this is my post!` or `~nebula/bink "this is also a post!"` will write all the words passed into it as a post for everyone else to see
`~nebula/bink pipe`: allow standard input to be the post body, eg. `echo "hello world!" | ~nebula/bink pipe`
`~nebula/bink --pipe`: allow standard input to be the post body, eg. `echo "hello world!" | ~nebula/bink pipe`
`~nebula/bink dump`: dumps all post data to a json object
`~nebula/bink --dump`: dumps all post data to a json object
## object logic

10
bink.py
View File

@ -50,13 +50,14 @@ def generate_feed(before=None, count=200):
blogs.append(obj)
return blogs
if argv[-1] == "--help" or argv[-1] == "help":
if len(argv) > 1:
if argv[1] == "--help":
exit("see https://git.tilde.town/nebula/bink for usage instructions")
elif argv[-1] == "dump":
elif argv[1] == "--dump":
with open("/dev/stdout", "w") as f:
json.dump(generate_feed(), f)
exit()
elif argv[-1] == "pipe":
elif argv[1] == "--pipe":
try:
with open("/dev/stdin", "r", encoding="UTF-8") as f:
body = f.read().strip()
@ -65,8 +66,7 @@ elif argv[-1] == "pipe":
exit()
except KeyboardInterrupt:
exit()
if len(argv) > 1:
else:
create_post(" ".join(argv[1:]))
exit()