From 6d98e2a755f7bb2fc38e843827a7e106574cd1b5 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Fri, 26 May 2023 15:01:56 -0500 Subject: [PATCH] developdevelopdevelop --- src/viv/viv.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/viv/viv.py b/src/viv/viv.py index d71b046..e884c20 100755 --- a/src/viv/viv.py +++ b/src/viv/viv.py @@ -51,7 +51,7 @@ from typing import ( Generator, ) -__version__ = "22.12a3-51-g0939736-dev" +__version__ = "22.12a3-52-g312ed47-dev" @dataclass @@ -807,7 +807,7 @@ class ArgumentParser(StdArgParser): description = f""" {a.tagline()} -{a.style('to create/activate a vivenv','underline')}: +to create/activate a vivenv: - from command line: `{a.style("viv -h","bold")}` - within python script: {a.style('__import__("viv").use("typer", "rich-click")','bold')} """ @@ -861,7 +861,11 @@ class Viv: try: self.local_source = __import__("viv").__file__ except ImportError: - self.local_source = "NotFound" + self.local_source = "Not Found" + + self.git = self.local_source != "Not Found" and str(self.local_source).endswith( + "src/viv/__init__.py" + ) def _match_vivenv(self, name_id: str) -> ViVenv: # type: ignore[return] # TODO: improve matching algorithm to favor names over id's @@ -970,7 +974,10 @@ class Viv: vivenv.dump_info() def manage(self, args: Namespace) -> None: - """manage viv installation""" + """manage viv itself + + Can be used to install or update an existing viv installation + """ if args.cmd == "show": echo("Current:") sys.stdout.write( @@ -990,6 +997,12 @@ class Viv: 1, ) + if self.git: + error( + a.style("viv manage update", "bold") + + " shouldn't be used with a git-based installation", + 1, + ) sha256 = fetch_source(args.reference) sys.path.append(str(c.srccache)) next_version = __import__(sha256).__version__ @@ -1004,7 +1017,7 @@ class Viv: print("Holding off on the additions of this piece") elif args.cmd == "install": - if self.local_source: + if not self.local_source == "NotFound": error(f"found existing viv installation at {self.local_source}") echo( "use " @@ -1022,7 +1035,7 @@ class Viv: # TODO: src path and cli path should be shard args between update/install q = INSTALL_TEMPLATE.format( - src_location="~/.local/share/viv/viv.py", cli_location="~/bin/viv" + src_location=args.src, cli_location=args.cli ) + ("Would you like to perform the above " "installation steps?") if confirm(q): @@ -1152,8 +1165,7 @@ class Viv: p_manage_shared.add_argument( "-s", "--src", - help="path/to/source file", - # default = + help="path/to/source_file", default=c.srccache / "viv.py", ) p_manage_shared.add_argument(