added help messages

This commit is contained in:
Cameron
2021-05-20 02:00:12 -05:00
parent c8267824ae
commit b0950a5bec

View File

@@ -5,7 +5,6 @@ import tempfile
from sys import argv from sys import argv
from os import curdir, remove, walk from os import curdir, remove, walk
from os.path import splitext, join from os.path import splitext, join
#from glob import glob
from typing import Final from typing import Final
#optionally prints a message if the verbosity level is high enough #optionally prints a message if the verbosity level is high enough
@@ -16,15 +15,15 @@ vprint.verbosity = 0
def main(arguments): def main(arguments):
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('-e', '--ext', type=str) parser.add_argument('-e', '--ext', type=str, help='set output file extension (default "cbr")', default='cbz')
parser.add_argument('-p', '--path', type=str) parser.add_argument('-p', '--path', type=str, help='output path', default='.')
parser.add_argument('-d', '--delete', action='store_true') parser.add_argument('-d', '--delete', action='store_true', help='delete source file after successful conversion')
parser.add_argument('-v', action='count') parser.add_argument('-v', action='count', help='display additional information')
parser.add_argument('files', nargs='+', type=str) parser.add_argument('files', nargs='+', type=str)
args = parser.parse_args(arguments) args = parser.parse_args(arguments)
files = args.files files: Final = args.files
ext = args.ext or 'cbz' ext: Final = args.ext.lstrip('.')
delete = args.delete delete: Final = args.delete
path: Final = args.path or curdir path: Final = args.path or curdir
@@ -36,8 +35,8 @@ def main(arguments):
rar.extractall(dir) rar.extractall(dir)
z_f = join(path, splitext(f)[0] + '.' + ext) z_f = join(path, splitext(f)[0] + '.' + ext)
with zipfile.ZipFile(z_f, 'x') as zip: with zipfile.ZipFile(z_f, 'x') as zip:
for dirpath, dirs, files in walk(dir): for dirpath, dirs, fs in walk(dir):
for file in files: for file in fs:
p = join(dirpath, file) p = join(dirpath, file)
zip.write(p) zip.write(p)
vprint('finished ' + z_f, 0) vprint('finished ' + z_f, 0)