diff --git a/docs/parameterized_goals.md b/docs/parameterized_goals.md index bb3e3c5..4636a6c 100644 --- a/docs/parameterized_goals.md +++ b/docs/parameterized_goals.md @@ -94,4 +94,10 @@ On encounter `@depends_on` generate instantiated? But this needs to go in-depth. ### PG + @glob TODO ### PG + @private -TODO \ No newline at end of file +TODO +### PG + @lib +TODO +### PG + @reached_if +TODO +### PG + @doc +TODO diff --git a/makesure.awk b/makesure.awk index cf6b39b..4ca106f 100755 --- a/makesure.awk +++ b/makesure.awk @@ -616,9 +616,14 @@ function instantiateGoals( i,l,goalName) { for (i = 0; i < l; i++) if (GoalParamsCnt[goalName = GoalNames[i]] == 0) instantiate(goalName) + # should not be possible to list or invoke (non-instantiated) parameterized goals, so let's remove them + for (goalName in GoalsByName) + if (GoalParamsCnt[goalName] > 0) { + arrDel(GoalNames, goalName) + delete GoalsByName[goalName] + } } #function renderArgs(args, s,k) { s = ""; for (k in args) s = s k "=>" args[k] " "; return s } -function copyKey(keySrc,keyDst,arr) { if (keySrc in arr) arr[keyDst] = arr[keySrc] } # # args: { F => "file1" } # @@ -856,10 +861,20 @@ function addLine(target, line) { target[0] = addL(target[0], line) } function addL(s, l) { return s ? s "\n" l : l } function arrPush(arr, elt) { arr[arr[-7]++] = elt } function arrLen(arr) { return +arr[-7] } +function arrDel(arr, v, l,i,e,resArr) { + l = arrLen(arr) + for (i=0; i0 ? arr[l-1] : "" } function commandExists(cmd) { return ok("command -v " cmd " >/dev/null") } function ok(cmd) { return system(cmd) == 0 } function isFile(path) { return ok("test -f " quoteArg(path)) } function rm(f) { system("rm " quoteArg(f)) } function quoteArg(a) { gsub("'", "'\\''", a); return "'" a "'" } -function trim(s) { sub(/^[ \t\r\n]+/, "", s); sub(/[ \t\r\n]+$/, "", s); return s } \ No newline at end of file +function trim(s) { sub(/^[ \t\r\n]+/, "", s); sub(/[ \t\r\n]+$/, "", s); return s } +function copyKey(keySrc,keyDst,arr) { if (keySrc in arr) arr[keyDst] = arr[keySrc] } \ No newline at end of file diff --git a/tests/27_parameterized_goals.tush b/tests/27_parameterized_goals.tush new file mode 100644 index 0000000..0d14704 --- /dev/null +++ b/tests/27_parameterized_goals.tush @@ -0,0 +1,22 @@ + +$ cd "$MYDIR"; ./$MAKESURE -f tests/27_parameterized_goals_1.sh -l +| Available goals: +| a +| b@hello + +$ cd "$MYDIR"; ./$MAKESURE -f tests/27_parameterized_goals_1.sh -la +| Available goals: +| a +| b@hello + +$ cd "$MYDIR"; ./$MAKESURE -f tests/27_parameterized_goals_2.sh -l +| Available goals: +| a +| b@hello +| c@hello + +$ cd "$MYDIR"; ./$MAKESURE -f tests/27_parameterized_goals_2.sh -la +| Available goals: +| a +| b@hello +| c@hello