From cf2c9714e2efff0ab652d329ea33cd352c595dfc Mon Sep 17 00:00:00 2001 From: Jacob Dallas <10dallasj@gmail.com> Date: Fri, 9 Sep 2022 10:43:41 -0500 Subject: [PATCH] Ability to set output path Added a flag to set the name of the output file. If nothing is provided, defaults to index.html --- diff2HtmlCompare.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/diff2HtmlCompare.py b/diff2HtmlCompare.py index 644ce93..711591a 100644 --- a/diff2HtmlCompare.py +++ b/diff2HtmlCompare.py @@ -413,13 +413,19 @@ def show(outputpath): parser.add_argument('-p', '--print-width', action='store_true', help='Restrict code to 80 columns wide. (printer friendly in landscape)') parser.add_argument('-c', '--syntax-css', action='store', default="vs", - help='Pygments CSS for code syntax highlighting. Can be one of: %s' % str(PYGMENTS_STYLES)) + help='Pygments CSS for code syntax highlighting. Can be one of: %s' % str(PYGMENTS_STYLE S)) parser.add_argument('-v', '--verbose', action='store_true', help='show verbose output.') + parser.add_argument('-o', "--output", action="store", help="Output file location") parser.add_argument('file1', help='source file to compare ("before" file).') parser.add_argument('file2', help='source file to compare ("after" file).') args = parser.parse_args() - + + if args.output is None: + outputpath = "index.html" + else: + outputpath = str(args.output) if str(args.output).endswith(".html") else str(args.output + '.html') + if args.syntax_css not in PYGMENTS_STYLES: raise ValueError("Syntax CSS (-c) must be one of %r." % PYGMENTS_STYLES)