Skip to content

Commit

Permalink
Add simple key press handler for exit
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloLec committed Sep 29, 2021
1 parent 4538ee6 commit 96c0a92
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions livelog/reader.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# -*- coding: utf-8 -*-

from typing import Union
from sys import argv
from os import system, name, SEEK_END
from os import _exit, system, name, SEEK_END
from shutil import get_terminal_size
from time import sleep
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler, DirModifiedEvent, FileModifiedEvent
from colorama import Style
Expand Down Expand Up @@ -59,6 +57,7 @@ def on_modified(self, event: Union[DirModifiedEvent, FileModifiedEvent, None]):
"""

self.clear()
print(Style.RESET_ALL)
tail(self._file, get_terminal_size(fallback=(120, 50))[1])
print(Style.RESET_ALL)

Expand All @@ -76,8 +75,8 @@ def start_reader(file: str):
observer.start()

try:
while True:
sleep(1)
input("")
_exit(1)

finally:
observer.stop()
Expand Down

0 comments on commit 96c0a92

Please sign in to comment.