From 6d0fafdd00c46b7cfb47e3f6fa77322bfd32be3c Mon Sep 17 00:00:00 2001 From: nebula Date: Mon, 21 Apr 2025 06:18:31 +0000 Subject: [PATCH] change arguments --- README.md | 6 ++++-- bink.py | 36 ++++++++++++++++++------------------ 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index e03dd5a..d9a6c26 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/bink.py b/bink.py index 430e503..9d45d99 100755 --- a/bink.py +++ b/bink.py @@ -50,25 +50,25 @@ def generate_feed(before=None, count=200): blogs.append(obj) return blogs -if argv[-1] == "--help" or argv[-1] == "help": - exit("see https://git.tilde.town/nebula/bink for usage instructions") -elif argv[-1] == "dump": - with open("/dev/stdout", "w") as f: - json.dump(generate_feed(), f) - exit() -elif argv[-1] == "pipe": - try: - with open("/dev/stdin", "r", encoding="UTF-8") as f: - body = f.read().strip() - if body: - create_post(body) - exit() - except KeyboardInterrupt: - exit() - if len(argv) > 1: - create_post(" ".join(argv[1:])) - exit() + if argv[1] == "--help": + exit("see https://git.tilde.town/nebula/bink for usage instructions") + elif argv[1] == "--dump": + with open("/dev/stdout", "w") as f: + json.dump(generate_feed(), f) + exit() + elif argv[1] == "--pipe": + try: + with open("/dev/stdin", "r", encoding="UTF-8") as f: + body = f.read().strip() + if body: + create_post(body) + exit() + except KeyboardInterrupt: + exit() + else: + create_post(" ".join(argv[1:])) + exit() import urwid