Skip to content

Commit 5e792de

Browse files
author
Peter Amstutz
committed
Tweak behavior of --relative-deps to select between relative primary path or
from cwd.
1 parent ffa747e commit 5e792de

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

cwltool/main.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ def arg_parser():
121121
exgroup.add_argument("--debug", action="store_true", help="Print even more logging")
122122

123123
parser.add_argument("--tool-help", action="store_true", help="Print command line help for tool")
124-
parser.add_argument("--relative-deps", action="store_true", help="When using --print-deps, print relative paths to dependencies.")
124+
125+
parser.add_argument("--relative-deps", choices=['primary', 'cwd'], default="primary",
126+
help="When using --print-deps, print paths relative to primary file or current working directory.")
125127

126128
parser.add_argument("--enable-net", action="store_true", help="Use docker's default network for container, default to disable network")
127129

@@ -462,13 +464,17 @@ def loadref(b, u):
462464
deps["secondaryFiles"] = sf
463465

464466
if relative_deps:
465-
base = basedir if basedir else os.path.dirname(obj["id"])
467+
if relative_deps == "primary":
468+
base = basedir if basedir else os.path.dirname(obj["id"])
469+
elif relative_deps == "cwd":
470+
base = "file://" + os.getcwd()
471+
else:
472+
raise Exception("Unknown relative_deps %s" % relative_deps)
466473
def makeRelative(u):
467474
if ":" in u.split("/")[0] and not u.startswith("file://"):
468475
return u
469476
return os.path.relpath(u, base)
470-
process.adjustFiles(sf, makeRelative)
471-
deps["path"] = os.path.basename(deps["path"])
477+
process.adjustFiles(deps, makeRelative)
472478

473479
stdout.write(json.dumps(deps, indent=4))
474480

0 commit comments

Comments
 (0)