Some cli improvements
- Adds cross platform clear console functionality - Replaces "search_for_metadata" if tree with a match case - Implements alternative command interface for handling the program - Fixes bug of error being displayed when quitting the program
This commit is contained in:
parent
fe1c849852
commit
ad446a1099
3
.gitignore
vendored
3
.gitignore
vendored
@ -10,3 +10,6 @@ __pycache__/
|
||||
|
||||
/build/*
|
||||
!/build/build.sh
|
||||
|
||||
# Virtual Environment
|
||||
venv
|
||||
|
@ -1,3 +1,4 @@
|
||||
from .utils.functions import *
|
||||
from .utils.shared import *
|
||||
|
||||
from .metadata import (
|
||||
@ -37,24 +38,42 @@ def get_existing_genre():
|
||||
|
||||
|
||||
def search_for_metadata():
|
||||
clear_console()
|
||||
|
||||
search = metadata_search.Search()
|
||||
|
||||
while True:
|
||||
input_ = input(
|
||||
"q to quit, .. for previous options, int for this element, str to search for query, ok to download\n")
|
||||
input_.strip()
|
||||
if input_.lower() == "ok":
|
||||
"""
|
||||
- - - Type the command you want to execute - - -
|
||||
.. - Previous Options
|
||||
(query_string) - Search for songs, albums, bands...
|
||||
(int) - Select an item from the search results
|
||||
d - Start the download
|
||||
h - Help
|
||||
q - Quit / Exit
|
||||
|
||||
command: """
|
||||
)
|
||||
|
||||
match (input_.strip().lower()):
|
||||
case "d" | "ok" | "dl" | "download":
|
||||
break
|
||||
if input_.lower() == "q":
|
||||
break
|
||||
if input_.lower() == "..":
|
||||
case "q" | "quit" | "exit":
|
||||
clear_console()
|
||||
exit()
|
||||
case "h" | "help":
|
||||
print()
|
||||
print(search.get_previous_options())
|
||||
continue
|
||||
if input_.isdigit():
|
||||
# TODO: Help text (mainly explaining query strings and alternative command functionalities)
|
||||
print("Insert here help text....")
|
||||
case inp if inp.isdigit():
|
||||
print()
|
||||
print(search.choose(int(input_)))
|
||||
continue
|
||||
case ".." :
|
||||
print()
|
||||
print(search.get_previous_options())
|
||||
|
||||
print()
|
||||
print(search.search_from_query(input_))
|
||||
|
||||
@ -81,6 +100,8 @@ def get_genre():
|
||||
|
||||
|
||||
def cli(start_at: int = 0, only_lyrics: bool = False):
|
||||
clear_console()
|
||||
|
||||
if start_at <= 2 and not only_lyrics:
|
||||
genre = get_genre()
|
||||
logging.info(f"{genre} has been set as genre.")
|
||||
@ -107,3 +128,7 @@ def cli(start_at: int = 0, only_lyrics: bool = False):
|
||||
if start_at <= 4:
|
||||
logging.info("starting to fetch the lyrics")
|
||||
lyrics.fetch_lyrics()
|
||||
|
||||
|
||||
def gtk_gui():
|
||||
pass
|
||||
|
@ -1,2 +1,2 @@
|
||||
# tells what exists
|
||||
__all__ = ["shared", "object_handeling", "phonetic_compares"]
|
||||
__all__ = ["shared", "object_handeling", "phonetic_compares", "functions"]
|
||||
|
4
src/music_kraken/utils/functions.py
Normal file
4
src/music_kraken/utils/functions.py
Normal file
@ -0,0 +1,4 @@
|
||||
import os
|
||||
|
||||
def clear_console():
|
||||
os.system('cls' if os.name in ('nt', 'dos') else 'clear')
|
Loading…
Reference in New Issue
Block a user