fix(#18): use --bin to determine default filename

This commit is contained in:
Daylin Morgan 2024-04-18 14:31:00 -05:00
parent c5bc03f497
commit 4c236e96eb
Signed by: daylin
GPG key ID: 950D13E9719334AD

View file

@ -3452,9 +3452,9 @@ class Viv:
"`python3 <(curl -fsSL viv.dayl.in/viv.py) manage install`" "`python3 <(curl -fsSL viv.dayl.in/viv.py) manage install`"
) )
def _pick_bin(self, reqs: List[str], bin: str) -> Tuple[str, str]: def _pick_bin(self, reqs: List[str], bin: str) -> str:
default = system.bin(re.split(r"[=><~!*]+", reqs[0])[0]) default = system.bin(re.split(r"[=><~!*]+", reqs[0])[0])
return default, (default if not bin else bin) return default if not bin else bin
def cmd_shim( def cmd_shim(
self, self,
@ -3475,8 +3475,8 @@ class Viv:
viv shim yartsu -o ~/bin/yartsu --standalone viv shim yartsu -o ~/bin/yartsu --standalone
""" """
default_bin, bin = self._pick_bin(reqs, bin) bin = self._pick_bin(reqs, bin)
output = Env().viv_bin_dir / default_bin if not output else output.absolute() output = Env().viv_bin_dir / bin if not output else output.absolute()
if freeze: if freeze:
spec = resolve_deps(reqs, requirements) spec = resolve_deps(reqs, requirements)
@ -3520,7 +3520,7 @@ class Viv:
if script: if script:
Script(path=script, spec=spec, keep=keep, rest=rest, viv=self).run() Script(path=script, spec=spec, keep=keep, rest=rest, viv=self).run()
else: else:
_, bin = self._pick_bin(reqs, bin) bin = self._pick_bin(reqs, bin)
vivenv = ViVenv(spec) vivenv = ViVenv(spec)
with vivenv.use(keep=keep): with vivenv.use(keep=keep):