Create parser factory
This commit is contained in:
parent
bef6ad9438
commit
749750fbb7
@ -3,10 +3,8 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import convert_file_encoding
|
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(
|
parser = subparsers.add_parser(
|
||||||
'convert',
|
'convert',
|
||||||
description='Recursively convert .cue and .log files from cp1251 to utf-8',
|
description='Recursively convert .cue and .log files from cp1251 to utf-8',
|
||||||
@ -19,6 +17,12 @@ if __name__ == "__main__":
|
|||||||
)
|
)
|
||||||
parser.set_defaults(func=convert_file_encoding.execute)
|
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()
|
args = top_parser.parse_args()
|
||||||
print(args)
|
print(args)
|
||||||
args.func(args)
|
args.func(args)
|
||||||
|
Loading…
Reference in New Issue
Block a user