From 81dcd5e4c51fcdaeefb982e7e907ffddc1066d9c Mon Sep 17 00:00:00 2001 From: Peter Hatina Date: Sat, 11 Jan 2020 12:39:13 +0100 Subject: [PATCH] Add CLI option to open generated invoice Signed-off-by: Peter Hatina --- lib/invoice/cli.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/invoice/cli.py b/lib/invoice/cli.py index bdd334b..572d195 100644 --- a/lib/invoice/cli.py +++ b/lib/invoice/cli.py @@ -77,6 +77,7 @@ class Application: subparser = subparsers.add_parser(action+suffix, help=method.__doc__) if method == self.do_pdf: subparser.add_argument("--generate", "-g", action="store_true") + subparser.add_argument("--view", "-v", action="store_true") if action == "delete": subparser.add_argument("--force", "-f", action="store_true") if action == "new": @@ -158,7 +159,7 @@ class Application: item = self.db.invoices[selector] self._show(item._path) - def do_pdf(self, selector, generate): + def do_pdf(self, selector, generate, view): """Generate and view a PDF invoice. This requires Tempita 0.5. @@ -214,8 +215,9 @@ class Application: os.rename(tmp_pdf_file, pdf_file) assert(os.path.exists(pdf_file)) - #log.debug("Running PDF viewer...") - #subprocess.call((self.pdf_program, pdf_file)) + if view: + log.debug("Running PDF viewer...") + subprocess.call((self.pdf_program, pdf_file)) def _check_path(self, path): if not os.path.exists(path):