mirror of
https://github.com/daylinmorgan/viv.git
synced 2024-12-22 02:30:44 -06:00
fix: accept args with -s to make shebangs work better
This commit is contained in:
parent
2e916cab5f
commit
da77259862
2 changed files with 10 additions and 8 deletions
|
@ -4,14 +4,10 @@
|
|||
# Script Dependencies:
|
||||
# requests
|
||||
# rich # Needed for the output
|
||||
#
|
||||
# # Not needed - just to show that fragments in URLs do not
|
||||
# # get treated as comments
|
||||
# pip @ https://github.com/pypa/pip/archive/1.3.1.zip#sha1=2e15a2d4e7e9f394a9c7a6c905c6a239402a6442
|
||||
|
||||
import requests
|
||||
from rich.pretty import pprint
|
||||
from rich import print
|
||||
|
||||
resp = requests.get("https://peps.python.org/api/peps.json")
|
||||
data = resp.json()
|
||||
pprint([(k, v["title"]) for k, v in data.items()][:10])
|
||||
print([(k, v["title"]) for k, v in data.items()][:10])
|
||||
|
|
|
@ -52,7 +52,7 @@ from typing import (
|
|||
Union,
|
||||
)
|
||||
|
||||
__version__ = "2023.1002"
|
||||
__version__ = "2023.1002-dev"
|
||||
|
||||
|
||||
class Spinner:
|
||||
|
@ -1792,7 +1792,9 @@ class Viv:
|
|||
examples:
|
||||
viv r pycowsay -- "viv isn't venv\!"
|
||||
viv r rich -b python -- -m rich
|
||||
viv r -s <remote python script>
|
||||
viv r -s <python script>
|
||||
|
||||
note: any args after `-s <python script>` will be passed on
|
||||
"""
|
||||
|
||||
spec = combined_spec(reqs, requirements)
|
||||
|
@ -2127,6 +2129,10 @@ class Cli:
|
|||
i = sys.argv.index("--")
|
||||
args = self.parser.parse_args(sys.argv[1:i])
|
||||
args.rest = sys.argv[i + 1 :]
|
||||
elif flag := list({"-s", "--script"} & set(sys.argv)):
|
||||
i = sys.argv.index(flag[0])
|
||||
args = self.parser.parse_args(sys.argv[1 : i + 2])
|
||||
args.rest = sys.argv[i + 2 :]
|
||||
else:
|
||||
args = self.parser.parse_args()
|
||||
if args.func.__name__ in ("cmd_run", "cmd_exe"):
|
||||
|
|
Loading…
Reference in a new issue