refactored cli

This commit is contained in:
Hellow2
2023-06-20 16:40:34 +02:00
parent 08b47b7f59
commit f95083050e
13 changed files with 209 additions and 199 deletions

View File

@@ -1,4 +1 @@
from .config import config, read, write
# tells what exists
__all__ = ["shared", "object_handeling", "phonetic_compares", "functions"]
from .config import config, read_config, write_config

View File

@@ -4,7 +4,20 @@ from .connection import CONNECTION_SECTION
from .misc import MISC_SECTION
from .paths import PATHS_SECTION
from .config import read, write, config
from .paths import LOCATIONS
from .config import Config
read()
config = Config()
def read_config():
if not LOCATIONS.CONFIG_FILE.is_file():
write_config()
config.read_from_config_file(LOCATIONS.CONFIG_FILE)
def write_config():
config.write_to_config_file(LOCATIONS.CONFIG_FILE)
set_name_to_value = config.set_name_to_value

View File

@@ -125,16 +125,3 @@ class Config:
for section in self._section_list:
for name, attribute in section.name_attribute_map.items():
yield attribute
config = Config()
def read():
if not LOCATIONS.CONFIG_FILE.is_file():
write()
config.read_from_config_file(LOCATIONS.CONFIG_FILE)
def write():
config.write_to_config_file(LOCATIONS.CONFIG_FILE)

View File

@@ -105,3 +105,18 @@ THREADED = False
ENABLE_RESULT_HISTORY: bool = MISC_SECTION.ENABLE_RESULT_HISTORY.object_from_value
HISTORY_LENGTH: int = MISC_SECTION.HISTORY_LENGTH.object_from_value
HELP_MESSAGE = """
to search:
> s: {query or url}
> s: https://musify.club/release/some-random-release-183028492
> s: #a {artist} #r {release} #t {track}
to download:
> d: {option ids or direct url}
> d: 0, 3, 4
> d: 1
> d: https://musify.club/release/some-random-release-183028492
have fun :3
""".strip()