maybe fix some exit problems

This commit is contained in:
nebula 2025-04-23 22:57:29 +00:00
parent 0cbeb75a30
commit b375af7298

13
bink.py
View File

@ -57,23 +57,24 @@ def generate_feed(before=None, count=200):
if len(sys.argv) > 1: if len(sys.argv) > 1:
if sys.argv[1] == "--help" or sys.argv[1] == "-h": if sys.argv[1] == "--help" or sys.argv[1] == "-h":
exit(helptext) print(helptext)
exit(0)
elif sys.argv[1] == "--dump": elif sys.argv[1] == "--dump":
with open("/dev/stdout", "w") as f: with open("/dev/stdout", "w") as f:
json.dump(generate_feed(), f) json.dump(generate_feed(), f)
exit() exit(0)
elif sys.argv[1] == "--pipe": elif sys.argv[1] == "--pipe":
try: try:
with open("/dev/stdin", "r", encoding="UTF-8") as f: with open("/dev/stdin", "r", encoding="UTF-8") as f:
body = f.read().strip() body = f.read().strip()
if body: if body:
create_post(body) create_post(body)
exit() exit(0)
except KeyboardInterrupt: except KeyboardInterrupt:
exit() exit(0)
else: else:
create_post(" ".join(sys.argv[1:])) create_post(" ".join(sys.argv[1:]))
exit() exit(0)
import urwid import urwid
@ -128,7 +129,7 @@ class App():
def exit(self, message=""): def exit(self, message=""):
app.loop.stop() app.loop.stop()
run(["clear"]) run(["clear"])
exit(message) exit(0)
class ActionBox(urwid.ListBox): class ActionBox(urwid.ListBox):
def keypress(self, size, key): def keypress(self, size, key):