From 749750fbb705267c5f9e330250b1700c0d8eb97b Mon Sep 17 00:00:00 2001 From: Anton Vakhrushev Date: Sat, 26 Apr 2025 15:25:05 +0300 Subject: [PATCH] Create parser factory --- music-tools.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/music-tools.py b/music-tools.py index 7c075af..95fc172 100755 --- a/music-tools.py +++ b/music-tools.py @@ -3,10 +3,8 @@ import argparse import convert_file_encoding -if __name__ == "__main__": - top_parser = argparse.ArgumentParser() - subparsers = top_parser.add_subparsers() - + +def create_convert_parser(subparsers): parser = subparsers.add_parser( 'convert', description='Recursively convert .cue and .log files from cp1251 to utf-8', @@ -18,6 +16,12 @@ if __name__ == "__main__": help='Path to target directory for conversion' ) parser.set_defaults(func=convert_file_encoding.execute) + + +if __name__ == "__main__": + top_parser = argparse.ArgumentParser() + subparsers = top_parser.add_subparsers() + create_convert_parser(subparsers) args = top_parser.parse_args() print(args)