moved cli to __init__.py
This commit is contained in:
parent
42d393389a
commit
658837850c
@ -1,36 +1,7 @@
|
||||
import music_kraken
|
||||
from music_kraken import pages
|
||||
|
||||
|
||||
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()
|
||||
|
||||
while True:
|
||||
next_search(search, input(">> "))
|
||||
print(search)
|
||||
|
||||
|
||||
def search_pages():
|
||||
search = pages.Search()
|
||||
print("metadata", search.pages)
|
||||
@ -49,4 +20,4 @@ def search_pages():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
cli()
|
||||
music_kraken.cli()
|
||||
|
@ -36,8 +36,31 @@ musicbrainzngs.set_useragent("metadata receiver", "0.1", "https://github.com/HeI
|
||||
|
||||
|
||||
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()
|
||||
|
||||
while True:
|
||||
search.next_input(input(">> "))
|
||||
next_search(search, input(">> "))
|
||||
print(search)
|
||||
|
Loading…
Reference in New Issue
Block a user