diff --git a/src/ytdl_sub/cli/main.py b/src/ytdl_sub/cli/main.py index b6b93548..c3267fbb 100644 --- a/src/ytdl_sub/cli/main.py +++ b/src/ytdl_sub/cli/main.py @@ -126,6 +126,7 @@ def main() -> List[Tuple[Subscription, FileHandlerTransactionLog]]: args, extra_args = parser.parse_known_args() + # Load the config config: ConfigFile = ConfigFile.from_file_path(args.config).initialize() transaction_logs: List[Tuple[Subscription, FileHandlerTransactionLog]] = [] @@ -155,6 +156,4 @@ def main() -> List[Tuple[Subscription, FileHandlerTransactionLog]]: 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 diff --git a/src/ytdl_sub/cli/main_args_parser.py b/src/ytdl_sub/cli/main_args_parser.py index 0c9eb295..b1d334f3 100644 --- a/src/ytdl_sub/cli/main_args_parser.py +++ b/src/ytdl_sub/cli/main_args_parser.py @@ -2,6 +2,7 @@ import argparse from enum import Enum from typing import List +from ytdl_sub import __local_version__ from ytdl_sub.utils.logger import LoggerLevels @@ -25,6 +26,7 @@ class MainArgs(Enum): parser = argparse.ArgumentParser( description="ytdl-sub: Automate download and adding metadata with YoutubeDL" ) +parser.add_argument("--version", action="version", version="%(prog)s " + __local_version__) parser.add_argument( "-c", MainArgs.CONFIG.value, diff --git a/src/ytdl_sub/main.py b/src/ytdl_sub/main.py index 09fb55c0..1f07ca53 100644 --- a/src/ytdl_sub/main.py +++ b/src/ytdl_sub/main.py @@ -27,6 +27,7 @@ def main(): logger = Logger.get() try: _main() + Logger.cleanup() # Ran successfully, so we can delete the debug file except ValidationException as validation_exception: logger.error(validation_exception) sys.exit(1) diff --git a/tests/unit/utils/test_logger.py b/tests/unit/utils/test_logger.py index 8d6ebec7..9509b546 100644 --- a/tests/unit/utils/test_logger.py +++ b/tests/unit/utils/test_logger.py @@ -10,7 +10,7 @@ from ytdl_sub.utils.logger import LoggerLevels def cleanup_debug_file(): Logger.set_log_level(log_level_name=LoggerLevels.DEBUG.name) yield - Logger.cleanup(delete_debug_file=True) + Logger.cleanup() class TestLogger: @@ -94,7 +94,8 @@ class TestLogger: 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) def test_logger_can_be_cleaned_during_execution(self):