mirror of
https://github.com/daylinmorgan/viv.git
synced 2024-12-22 02:30:44 -06:00
feat: add system flag to viv manage show
This commit is contained in:
parent
f91d6eb4b4
commit
68a6f3155a
1 changed files with 30 additions and 26 deletions
|
@ -242,6 +242,10 @@ class Ansi:
|
|||
)
|
||||
)
|
||||
|
||||
def key_value(self, items: Dict[str, Any], indent: str = " ") -> None:
|
||||
for k, v in items.items():
|
||||
sys.stderr.write(f"{indent}{a.bold}{k}{a.end}: {v}\n")
|
||||
|
||||
def subprocess(self, command: List[str], output: str) -> None:
|
||||
"""generate output for subprocess error
|
||||
|
||||
|
@ -504,24 +508,6 @@ if __name__ == "__main__":
|
|||
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def show(
|
||||
cli: Optional[Path | str], running: Path, local: Optional[Path | str]
|
||||
) -> str:
|
||||
return (
|
||||
"\n".join(
|
||||
f" {a.bold}{k}{a.end}: {v}"
|
||||
for k, v in (
|
||||
("Version", __version__),
|
||||
("CLI", cli),
|
||||
("Running Source", running),
|
||||
("Local Source", local),
|
||||
("Cache", Cfg().cache_base),
|
||||
)
|
||||
)
|
||||
+ "\n"
|
||||
)
|
||||
|
||||
|
||||
# TODO: convert the below functions into a proper file/stream logging interface
|
||||
def echo(
|
||||
|
@ -1563,6 +1549,7 @@ class Viv:
|
|||
def cmd_manage_show(
|
||||
self,
|
||||
pythonpath: bool = False,
|
||||
system: bool = False,
|
||||
) -> None:
|
||||
"""manage viv itself"""
|
||||
if pythonpath:
|
||||
|
@ -1571,13 +1558,29 @@ class Viv:
|
|||
else:
|
||||
err_quit("expected to find a local installation")
|
||||
else:
|
||||
echo("Current:")
|
||||
sys.stderr.write(
|
||||
self.t.show(
|
||||
cli=shutil.which("viv"),
|
||||
running=self.running_source,
|
||||
local=self.local_source,
|
||||
echo(f"{a.yellow}Current{a.end}:")
|
||||
a.key_value(
|
||||
{
|
||||
"Version": __version__,
|
||||
"CLI": shutil.which("viv"),
|
||||
"Running Source": self.running_source,
|
||||
"Local Source": self.local_source,
|
||||
"Cache": Cfg().cache_base,
|
||||
}
|
||||
)
|
||||
|
||||
if system:
|
||||
import platform # noqa
|
||||
|
||||
echo(f"{a.yellow}System{a.end}:")
|
||||
a.key_value(
|
||||
{
|
||||
"Python Exe": sys.executable,
|
||||
"Python Version": platform.sys.version,
|
||||
"Pip": subprocess_run(
|
||||
["pip", "--version"], check_output=True
|
||||
).strip(),
|
||||
}
|
||||
)
|
||||
|
||||
def cmd_manage_update(
|
||||
|
@ -1941,7 +1944,8 @@ class Cli:
|
|||
BoolArg(
|
||||
flag="pythonpath",
|
||||
help="show the path/to/install",
|
||||
)
|
||||
),
|
||||
BoolArg(flag="system", help="show system/python info too"),
|
||||
],
|
||||
("exe",): [
|
||||
Arg(
|
||||
|
|
Loading…
Reference in a new issue