implemented new cli
This commit is contained in:
parent
2b1b62f1dc
commit
214b04d7cc
@ -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)
|
||||||
|
|
||||||
|
|
||||||
|
@ -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):
|
||||||
self._current_option = self._previous_options
|
try:
|
||||||
|
self._current_option = self._previous_options
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user