diff --git a/src/nimblepkg/nimscriptwrapper.nim b/src/nimblepkg/nimscriptwrapper.nim index 10cfae8..fa8f8f0 100644 --- a/src/nimblepkg/nimscriptwrapper.nim +++ b/src/nimblepkg/nimscriptwrapper.nim @@ -40,10 +40,18 @@ proc execNimscript(nimsFile, projectDir, actionName: string, options: Options): if not isScriptResultCopied: nimsFileCopied.removeFile() - let + var cmd = ("nim e --hints:off --verbosity:0 -p:" & (getTempDir() / "nimblecache").quoteShell & " " & nimsFileCopied.quoteShell & " " & outFile.quoteShell & " " & actionName).strip() + if options.action.typ == actionCustom and actionName != "printPkgInfo": + for i in options.action.arguments: + cmd &= " " & i.quoteShell() + for key, val in options.action.flags.pairs(): + cmd &= " $#$#" % [if key.len == 1: "-" else: "--", key] + if val.len != 0: + cmd &= ":" & val.quoteShell() + displayDebug("Executing " & cmd) result.exitCode = execCmd(cmd) diff --git a/tests/issue633/issue633.nimble b/tests/issue633/issue633.nimble new file mode 100644 index 0000000..cb786eb --- /dev/null +++ b/tests/issue633/issue633.nimble @@ -0,0 +1,16 @@ +# Package + +version = "0.1.0" +author = "GT" +description = "Package for ensuring that issue #633 is resolved." +license = "MIT" + +# Dependencies + +requires "nim >= 0.19.6" +# to reproduce dependency 2 must be before 1 + +task testTask, "Test": + for i in 0 .. paramCount(): + if paramStr(i) == "--testTask": + echo "Got it" diff --git a/tests/tester.nim b/tests/tester.nim index 09427e8..c2aefc3 100644 --- a/tests/tester.nim +++ b/tests/tester.nim @@ -864,3 +864,8 @@ test "do not install single dependency multiple times (#678)": let (output, exitCode) = execNimble("install", "-y") check exitCode == QuitSuccess check output.find("issue678_dependency_1@0.1.0 already exists") == -1 + +test "Passing command line arguments to a task (#633)": + cd "issue633": + var (output, exitCode) = execNimble("testTask --testTask") + check output.contains("Got it")