Use log.fatal instead of stderr.

This commit is contained in:
voussoir 2021-09-22 23:17:12 -07:00
parent 993367f6ba
commit 74df9d62ae
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB

View file

@ -27,6 +27,9 @@ from voussoirkit import betterhelp
from voussoirkit import pipeable from voussoirkit import pipeable
from voussoirkit import subproctools from voussoirkit import subproctools
from voussoirkit import winwhich from voussoirkit import winwhich
from voussoirkit import vlogging
log = vlogging.getLogger(__name__, 'tempeditor')
class NoEditor(Exception): class NoEditor(Exception):
pass pass
@ -73,16 +76,17 @@ def tempeditor_argparse(args):
initial_text = pipeable.input(args.initial_text, split_lines=False) initial_text = pipeable.input(args.initial_text, split_lines=False)
try: try:
text = tempeditor(initial_text=initial_text) text = tempeditor(initial_text=args.initial_text)
pipeable.stdout(text) pipeable.stdout(text)
return 0 return 0
except NoEditor as exc: except NoEditor as exc:
pipeable.stderr(exc) log.fatal(exc)
return 1 return 1
except BadStatus as exc: except BadStatus as exc:
pipeable.stderr(f'Command {exc.args[0]} returned status {exc.args[1]}.') log.fatal(f'Command {exc.args[0]} returned status {exc.args[1]}.')
return 1 return 1
@vlogging.main_decorator
def main(argv): def main(argv):
parser = argparse.ArgumentParser(description=__doc__) parser = argparse.ArgumentParser(description=__doc__)