Skip to content

Commit

Permalink
Clear the Terminal after entry selection and after download ends (Closes
Browse files Browse the repository at this point in the history
 #8)
  • Loading branch information
johnvictorfs committed Nov 17, 2019
1 parent ad284fc commit 3a6a2a5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions nyaacli/nyaa_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import inquirer

from nyaacli.colors import red, yellow, green, PromptTheme
from nyaacli.utils import clear_screen


def get_file_extension(path: str) -> str:
Expand Down Expand Up @@ -150,6 +151,8 @@ def search_torrent(search: str, episode: Optional[int] = None, dub: bool = False

answer = inquirer.prompt(questions, theme=PromptTheme())

clear_screen()

index_choice = answer['entry'] - 1

entry_choice = entries[index_choice]
Expand Down
5 changes: 4 additions & 1 deletion nyaacli/torrenting.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import libtorrent

from nyaacli.colors import red, green
from nyaacli.utils import clear_screen


def download_torrent(filename: str, result_filename: str = None, show_progress: bool = True, base_path: str = 'Anime'):
Expand Down Expand Up @@ -55,7 +56,9 @@ def download_torrent(filename: str, result_filename: str = None, show_progress:

os.rename(old_name, new_name)

print(f'Finished download, at: \'{green(new_name)}\' ')
clear_screen()

print(f'Finished download at: \'{green(new_name)}\' ')


if __name__ == '__main__':
Expand Down
9 changes: 9 additions & 0 deletions nyaacli/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import os


def clear_screen():
"""
Runs either 'cls' or 'clear' on the Terminal, 'cls' to clear Terminal on windows,
which will ignore the rest of the command, and 'clear' to clear on Linux/Mac OS
"""
os.system('cls||clear')

0 comments on commit 3a6a2a5

Please sign in to comment.