implemented new cli

This commit is contained in:
Hellow2 2023-03-30 10:07:42 +02:00
parent 2b1b62f1dc
commit 214b04d7cc
2 changed files with 27 additions and 2 deletions

View File

@ -2,10 +2,32 @@ from music_kraken import pages
def cli(): def cli():
def next_search(search: pages.Search, query: str):
query: str = query.strip()
parsed: str = query.lower()
if parsed == ".":
return
if parsed == "..":
search.goto_previous()
return
if parsed.isdigit():
search.choose_index(int(parsed))
return
page = search.get_page_from_query(parsed)
if page is not None:
search.choose_page(page)
return
# if everything else is not valid search
search.search(query)
search = pages.Search() search = pages.Search()
while True: while True:
search.next_input(input(">> ")) next_search(search, input(">> "))
print(search) print(search)

View File

@ -176,4 +176,7 @@ class Search(Download):
mpo[page] = music_object.options mpo[page] = music_object.options
def goto_previous(self): def goto_previous(self):
try:
self._current_option = self._previous_options self._current_option = self._previous_options
except IndexError:
pass