developdevelopdevelop

This commit is contained in:
Daylin Morgan 2023-05-26 15:01:56 -05:00
parent 312ed47381
commit 6d98e2a755
Signed by: daylin
GPG key ID: C1E52E7DD81DF79F

View file

@ -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(