[BACKEND] Add --version arg (#499)
This commit is contained in:
parent
896a9e2073
commit
7b7a4f8ab1
4 changed files with 7 additions and 4 deletions
|
|
@ -126,6 +126,7 @@ def main() -> List[Tuple[Subscription, FileHandlerTransactionLog]]:
|
||||||
|
|
||||||
args, extra_args = parser.parse_known_args()
|
args, extra_args = parser.parse_known_args()
|
||||||
|
|
||||||
|
# Load the config
|
||||||
config: ConfigFile = ConfigFile.from_file_path(args.config).initialize()
|
config: ConfigFile = ConfigFile.from_file_path(args.config).initialize()
|
||||||
transaction_logs: List[Tuple[Subscription, FileHandlerTransactionLog]] = []
|
transaction_logs: List[Tuple[Subscription, FileHandlerTransactionLog]] = []
|
||||||
|
|
||||||
|
|
@ -155,6 +156,4 @@ def main() -> List[Tuple[Subscription, FileHandlerTransactionLog]]:
|
||||||
transaction_log.to_output_message(subscription.output_directory),
|
transaction_log.to_output_message(subscription.output_directory),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Ran successfully, so we can delete the debug file
|
|
||||||
Logger.cleanup(delete_debug_file=True)
|
|
||||||
return transaction_logs
|
return transaction_logs
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import argparse
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
|
from ytdl_sub import __local_version__
|
||||||
from ytdl_sub.utils.logger import LoggerLevels
|
from ytdl_sub.utils.logger import LoggerLevels
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -25,6 +26,7 @@ class MainArgs(Enum):
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description="ytdl-sub: Automate download and adding metadata with YoutubeDL"
|
description="ytdl-sub: Automate download and adding metadata with YoutubeDL"
|
||||||
)
|
)
|
||||||
|
parser.add_argument("--version", action="version", version="%(prog)s " + __local_version__)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-c",
|
"-c",
|
||||||
MainArgs.CONFIG.value,
|
MainArgs.CONFIG.value,
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ def main():
|
||||||
logger = Logger.get()
|
logger = Logger.get()
|
||||||
try:
|
try:
|
||||||
_main()
|
_main()
|
||||||
|
Logger.cleanup() # Ran successfully, so we can delete the debug file
|
||||||
except ValidationException as validation_exception:
|
except ValidationException as validation_exception:
|
||||||
logger.error(validation_exception)
|
logger.error(validation_exception)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ from ytdl_sub.utils.logger import LoggerLevels
|
||||||
def cleanup_debug_file():
|
def cleanup_debug_file():
|
||||||
Logger.set_log_level(log_level_name=LoggerLevels.DEBUG.name)
|
Logger.set_log_level(log_level_name=LoggerLevels.DEBUG.name)
|
||||||
yield
|
yield
|
||||||
Logger.cleanup(delete_debug_file=True)
|
Logger.cleanup()
|
||||||
|
|
||||||
|
|
||||||
class TestLogger:
|
class TestLogger:
|
||||||
|
|
@ -94,7 +94,8 @@ class TestLogger:
|
||||||
|
|
||||||
assert lines == ["[ytdl-sub:name_test] info test\n", "[ytdl-sub:name_test] debug test\n"]
|
assert lines == ["[ytdl-sub:name_test] info test\n", "[ytdl-sub:name_test] debug test\n"]
|
||||||
|
|
||||||
Logger.cleanup(delete_debug_file=True)
|
# Ensure the file cleans up too
|
||||||
|
Logger.cleanup()
|
||||||
assert not os.path.isfile(Logger._DEBUG_LOGGER_FILE.name)
|
assert not os.path.isfile(Logger._DEBUG_LOGGER_FILE.name)
|
||||||
|
|
||||||
def test_logger_can_be_cleaned_during_execution(self):
|
def test_logger_can_be_cleaned_during_execution(self):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue