From c5043ff3c3e2f974dbb2c582a194f1f8e8e19237 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Fri, 26 May 2023 17:49:20 -0500 Subject: [PATCH] this has gotten out of hand --- src/viv/viv.py | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/viv/viv.py b/src/viv/viv.py index 6b61f52..4ae0c72 100755 --- a/src/viv/viv.py +++ b/src/viv/viv.py @@ -51,7 +51,7 @@ from typing import ( Generator, ) -__version__ = "22.12a3-56-g4566e2e-dev" +__version__ = "22.12a3-57-g8277a54-dev" @dataclass @@ -578,11 +578,18 @@ SHOW_TEMPLATE = f""" """ INSTALL_TEMPLATE = f""" - Install viv.py to {a.bold}{{src_location}}{a.end} + Install viv.py to {a.green}{{src_location}}{a.end} Symlink {a.bold}{{src_location}}{a.end} to {a.bold}{{cli_location}}{a.end} """ +UPDATE_TEMPLATE = f""" + Update source at {a.green}{{src_location}}{a.end} + Symlink {a.bold}{{src_location}}{a.end} to {a.bold}{{cli_location}}{a.end} + Version {a.bold}{{local_version}}{a.end} -> {a.bold}{{next_version}}{a.end} + +""" + def noqa(txt: str) -> str: max_length = max(map(len, txt.splitlines())) @@ -1045,16 +1052,26 @@ class Viv: sys.path.append(str(c.srccache)) next_version = __import__(sha256).__version__ - q = ( - "Update source at: " - + a.style(self.running_source, "bold") - + f" \n from version {self.local_version} to {next_version}?" - ) + if self.local_version == next_version: + echo(f"no change between {args.reference} and local version") + sys.exit(0) - if confirm(q): + if confirm( + "Would you like to perform the above installation steps?", + UPDATE_TEMPLATE.format( + src_location=self.local_source, + local_version=self.local_version, + cli_location=args.cli, + next_version=next_version, + ), + ): self._install_local_src( sha256, - args.cli if self.local_source == "Not Found" else args.local_source, + Path( + args.src + if self.local_source == "Not Found" + else self.local_source, + ), args.cli, )