From bd18a473d417b36b36f87f86fc430e5dc997af6f Mon Sep 17 00:00:00 2001 From: joachimschmidt557 Date: Fri, 23 Aug 2019 18:52:40 +0200 Subject: [PATCH] ability to add custom work dir --- src/etherpad2latex.nim | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/etherpad2latex.nim b/src/etherpad2latex.nim index 57ecd8f..1eec0af 100644 --- a/src/etherpad2latex.nim +++ b/src/etherpad2latex.nim @@ -13,6 +13,7 @@ when isMainModule: help("Compiles etherpad pads to pdf") option("-p", "--port", help="Port for the server", default="8080") option("-a", "--etherpad-address", help="The address of the etherpad", default="http://localhost:9001") + option("-d", "--working-directory", help="The directory to use for saving and compiling", default=".") let opts = p.parse() @@ -21,13 +22,17 @@ when isMainModule: let pad = @"pad" etherpadUrl = opts.etherpadAddress + workingDir = opts.workingDirectory content = getContent(pad, etherpadUrl) - writeFile(pad & ".tex", content) + texFile = workingDir / pad & ".tex" + pdfFile = workingDir / pad & ".pdf" + + writeFile(texFile, content) - let (output, exitCode) = execCmdEx(quoteShellCommand(["pdflatex", "-halt-on-error", pad & ".tex"])) + let (output, exitCode) = execCmdEx(quoteShellCommand(["pdflatex", "-halt-on-error", texFile])) if exitCode == 0: - resp(Http200, readFile(pad & ".pdf"), contentType = "application/pdf") + resp(Http200, readFile(pdfFile), contentType = "application/pdf") else: resp output