From e7476a686343e128f15780d7ec35711f31185b58 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Sun, 28 May 2023 10:21:16 -0500 Subject: [PATCH] respect output --- src/viv/viv.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/viv/viv.py b/src/viv/viv.py index 718ebff..b41106f 100755 --- a/src/viv/viv.py +++ b/src/viv/viv.py @@ -52,7 +52,7 @@ from typing import ( from urllib.error import HTTPError from urllib.request import urlopen -__version__ = "23.5a1-14-gd7717ff" +__version__ = "23.5a1-14-g49164f8" class Config: @@ -1168,8 +1168,12 @@ class Viv: else: error("please specify an explicit -b/--bin and -o/--output", code=1) + if args.output: + output = args.output + if output.is_file(): error(f"{output} already exists...exiting", code=1) + if args.standalone: imports = STANDALONE_TEMPLATE.format( version=__version__, func=noqa(STANDALONE_TEMPLATE_FUNC) @@ -1194,11 +1198,13 @@ class Viv: imports = "" use = IMPORT_TEMPLATE.format(spec=spec) - # TODO: confirm next steps? - with output.open("w") as f: - f.write(SHIM_TEMPLATE.format(imports=imports, use=use, bin=bin)) + if confirm( + f"Write shim for {a.style(bin,'bold')} to {a.style(output,'green')}?" + ): + with output.open("w") as f: + f.write(SHIM_TEMPLATE.format(imports=imports, use=use, bin=bin)) - make_executable(output) + make_executable(output) def _get_subcmd_parser( self,