mirror of
https://github.com/daylinmorgan/viv.git
synced 2024-11-13 20:47:53 -06:00
wip
This commit is contained in:
parent
298e8b274c
commit
baad1783a2
1 changed files with 31 additions and 2 deletions
|
@ -52,7 +52,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.5a1-dev"
|
__version__ = "23.5a1-12-g298e8b2"
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
@ -593,6 +593,16 @@ UPDATE_TEMPLATE = f"""
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
SHIM_TEMPLATE = """\
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
vivenv = {use}
|
||||||
|
sys.exit(subprocess.run([vivenv.path / "bin" / "{bin}", *sys.argv[1:]]).returncode)
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
def noqa(txt: str) -> str:
|
def noqa(txt: str) -> str:
|
||||||
max_length = max(map(len, txt.splitlines()))
|
max_length = max(map(len, txt.splitlines()))
|
||||||
|
@ -1126,7 +1136,24 @@ class Viv:
|
||||||
|
|
||||||
def shim(self, args):
|
def shim(self, args):
|
||||||
"""generate viv-powered cli apps"""
|
"""generate viv-powered cli apps"""
|
||||||
echo("not implemented.")
|
if args.output.is_file():
|
||||||
|
error(f"{args.output} already exists...exiting", code=1)
|
||||||
|
|
||||||
|
# TODO: robustness....
|
||||||
|
|
||||||
|
spec = ", ".join(f'"{req}"' for req in args.reqs)
|
||||||
|
|
||||||
|
if args.bin:
|
||||||
|
bin = args.bin
|
||||||
|
elif len(args.reqs) == 1:
|
||||||
|
bin = args.reqs[0]
|
||||||
|
else:
|
||||||
|
error("please specify an explicit -b/--bin")
|
||||||
|
|
||||||
|
with args.output.open("w") as f:
|
||||||
|
f.write(SHIM_TEMPLATE.format(use=f'__import__("viv").use({spec})', bin=bin))
|
||||||
|
|
||||||
|
make_executable(args.output)
|
||||||
|
|
||||||
def _get_subcmd_parser(
|
def _get_subcmd_parser(
|
||||||
self,
|
self,
|
||||||
|
@ -1299,6 +1326,8 @@ class Viv:
|
||||||
"-o",
|
"-o",
|
||||||
"--output",
|
"--output",
|
||||||
help="path/to/output file",
|
help="path/to/output file",
|
||||||
|
required=True,
|
||||||
|
type=Path,
|
||||||
metavar="<path>",
|
metavar="<path>",
|
||||||
)
|
)
|
||||||
p_manage_shim.add_argument(
|
p_manage_shim.add_argument(
|
||||||
|
|
Loading…
Reference in a new issue