mirror of
https://github.com/daylinmorgan/viv.git
synced 2024-11-09 19:13:14 -06:00
feat: add -p to info
This commit is contained in:
parent
baa7f9cded
commit
4faa103ae6
1 changed files with 17 additions and 2 deletions
|
@ -50,7 +50,7 @@ from typing import (
|
||||||
from urllib.error import HTTPError
|
from urllib.error import HTTPError
|
||||||
from urllib.request import urlopen
|
from urllib.request import urlopen
|
||||||
|
|
||||||
__version__ = "23.5a5-22-gfac4b38-dev"
|
__version__ = "23.5a5-23-gbaa7f9c-dev"
|
||||||
|
|
||||||
|
|
||||||
class Spinner:
|
class Spinner:
|
||||||
|
@ -1094,15 +1094,18 @@ class Viv:
|
||||||
|
|
||||||
run(full_cmd, verbose=True)
|
run(full_cmd, verbose=True)
|
||||||
|
|
||||||
def info(self, vivenv_id: str, use_json: bool) -> None:
|
def info(self, vivenv_id: str, path: bool, use_json: bool) -> None:
|
||||||
"""get metadata about a vivenv"""
|
"""get metadata about a vivenv"""
|
||||||
vivenv = self._match_vivenv(vivenv_id)
|
vivenv = self._match_vivenv(vivenv_id)
|
||||||
metadata_file = vivenv.path / "vivmeta.json"
|
metadata_file = vivenv.path / "vivmeta.json"
|
||||||
|
|
||||||
if not metadata_file.is_file():
|
if not metadata_file.is_file():
|
||||||
error(f"Unable to find metadata for vivenv: {vivenv_id}", code=1)
|
error(f"Unable to find metadata for vivenv: {vivenv_id}", code=1)
|
||||||
|
|
||||||
if use_json:
|
if use_json:
|
||||||
sys.stdout.write(json.dumps(vivenv.meta.__dict__))
|
sys.stdout.write(json.dumps(vivenv.meta.__dict__))
|
||||||
|
elif path:
|
||||||
|
sys.stdout.write(f"{vivenv.path.absolute()}\n")
|
||||||
else:
|
else:
|
||||||
vivenv.tree()
|
vivenv.tree()
|
||||||
|
|
||||||
|
@ -1409,6 +1412,14 @@ class Cli:
|
||||||
metavar="<path>",
|
metavar="<path>",
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
("info",): [
|
||||||
|
Arg(
|
||||||
|
"-p",
|
||||||
|
"--path",
|
||||||
|
help="print the absolute path to the vivenv",
|
||||||
|
action="store_true",
|
||||||
|
),
|
||||||
|
],
|
||||||
("remove",): [
|
("remove",): [
|
||||||
Arg("vivenvs", help="name/hash of vivenv", nargs="*", metavar="vivenv")
|
Arg("vivenvs", help="name/hash of vivenv", nargs="*", metavar="vivenv")
|
||||||
],
|
],
|
||||||
|
@ -1602,6 +1613,10 @@ class Cli:
|
||||||
if not (args.reqs or args.script):
|
if not (args.reqs or args.script):
|
||||||
error("must specify a requirement or --script", code=1)
|
error("must specify a requirement or --script", code=1)
|
||||||
|
|
||||||
|
if args.func.__name__ == "info":
|
||||||
|
if args.use_json and args.path:
|
||||||
|
error("--json and -p/--path are mutually exclusive", code=1)
|
||||||
|
|
||||||
def _get_subcmd_parser(
|
def _get_subcmd_parser(
|
||||||
self,
|
self,
|
||||||
subparsers: _SubParsersAction[ArgumentParser],
|
subparsers: _SubParsersAction[ArgumentParser],
|
||||||
|
|
Loading…
Reference in a new issue