Add argparse for parsing command-line arguments.
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
b958a537de
commit
aa4e9e2184
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import argparse
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import docx
|
import docx
|
||||||
|
@ -73,9 +74,20 @@ def double_space_and_indent(paragraphs):
|
||||||
previous_paragraph_plaintext = this_paragraph_plaintext
|
previous_paragraph_plaintext = this_paragraph_plaintext
|
||||||
|
|
||||||
|
|
||||||
|
def parse_arguments(unparsed_arguments):
|
||||||
|
parser = argparse.ArgumentParser(add_help=True)
|
||||||
|
parser.add_argument(
|
||||||
|
metavar='FILENAME',
|
||||||
|
dest='document_filename',
|
||||||
|
help='Novel document to format',
|
||||||
|
)
|
||||||
|
|
||||||
|
parser.parse_args(unparsed_arguments)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
document_filename = sys.argv[1]
|
arguments = parse_arguments(sys.argv[1:])
|
||||||
document = docx.Document(document_filename)
|
document = docx.Document(arguments.document_filename)
|
||||||
|
|
||||||
set_default_font(document)
|
set_default_font(document)
|
||||||
# add_header_text(document, 'Author / Project Title / ')
|
# add_header_text(document, 'Author / Project Title / ')
|
||||||
|
@ -84,7 +96,7 @@ def main():
|
||||||
right_align_header(document)
|
right_align_header(document)
|
||||||
double_space_and_indent(document.paragraphs)
|
double_space_and_indent(document.paragraphs)
|
||||||
|
|
||||||
document.save(document_filename)
|
document.save(arguments.document_filename)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in New Issue