uvms: support args in app urls
This commit is contained in:
parent
42fca62474
commit
a13e9c9393
1 changed files with 13 additions and 6 deletions
|
|
@ -13,7 +13,7 @@ import json
|
|||
import re
|
||||
from argparse import ArgumentParser
|
||||
from contextlib import contextmanager, closing, ExitStack
|
||||
from urllib import urlparse
|
||||
from urllib.parse import urlparse, parse_qs
|
||||
|
||||
|
||||
parser = ArgumentParser("supervise-vm")
|
||||
|
|
@ -519,16 +519,21 @@ def main(args, args_next, cleanup, ps):
|
|||
app_paths = []
|
||||
for a in args.app:
|
||||
a = urlparse(a)
|
||||
nix_file = None
|
||||
nix_file = "./."
|
||||
attr = None
|
||||
if a.scheme == "":
|
||||
nix_file = "<nixpkgs>"
|
||||
attr = a.path
|
||||
elif a.scheme == "getexe":
|
||||
nix_file = a.netloc or "./."
|
||||
attr = a.path.lstrip("/")
|
||||
else:
|
||||
raise RuntimeError("Unknown app url", a)
|
||||
assert a.fragment, a
|
||||
attr = a.fragment
|
||||
nix_file = a.path or "./."
|
||||
arglist = []
|
||||
for k, v in parse_qs(a.query).items():
|
||||
arglist.append("--arg")
|
||||
arglist.append(k)
|
||||
arglist.append(v)
|
||||
|
||||
assert nix_file is not None, a
|
||||
assert attr is not None, a
|
||||
out_path = ps.exec(
|
||||
|
|
@ -536,7 +541,9 @@ def main(args, args_next, cleanup, ps):
|
|||
nix_file,
|
||||
"-A",
|
||||
attr,
|
||||
*arglist,
|
||||
"--no-out-link",
|
||||
cwd=os.getcwd(),
|
||||
capture_output=True,
|
||||
text=True,
|
||||
).stdout.strip()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue