18 lines
687 B
Python
18 lines
687 B
Python
import os
|
|
import argparse
|
|
from .models import BuildContext
|
|
|
|
|
|
def parse_args(ctx: BuildContext) -> bool:
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("fileName", help="File to process")
|
|
parser.add_argument("-f", "--force", help="Force overwrite an existing book directory", action="store_true")
|
|
parser.add_argument("-v", "--verbose", help="Provide updates while processing", action="store_true")
|
|
args = parser.parse_args()
|
|
ctx.book.filename = str(args.fileName)
|
|
if not os.path.isfile(ctx.book.filename):
|
|
print("File '{}' is not found. Exiting...".format(ctx.book.filename))
|
|
exit()
|
|
ctx.verbose = args.verbose
|
|
return args.force
|