diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-08-07 08:20:52 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-08-07 08:20:52 +0000 |
commit | 95c38e53af92ac6e545a68f68835db9bec214025 (patch) | |
tree | 0cbf0fddede19b03da33abfb266e100965fbffae /share | |
parent | a0d6d7571225a02c5dab3b73a76f0e90ec3ea641 (diff) | |
parent | eeb4289de025dfeb639cdd21136763e3af4b7dfb (diff) | |
download | subplot-95c38e53af92ac6e545a68f68835db9bec214025.tar.gz |
Merge branch 'main' into 'main'
bash template: Provice captures to cleanups
See merge request subplot/subplot!198
Diffstat (limited to 'share')
-rw-r--r-- | share/bash/template/template.sh.tera | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/share/bash/template/template.sh.tera b/share/bash/template/template.sh.tera index 6ee88f5..67134f3 100644 --- a/share/bash/template/template.sh.tera +++ b/share/bash/template/template.sh.tera @@ -88,9 +88,11 @@ files_set "$filename" "$contents" ###################################### # Scenario: {{ scenario.title }} scenario_{{ loop.index }}() { - local title scendir step name text ret cleanups steps + local title scendir step name text ret declare -a cleanups declare -a steps + declare -a cleanups_captures + declare -A captures title="$(decode_base64 '{{ scenario.title | base64 }}')" echo "scenario: $title" @@ -103,6 +105,7 @@ scenario_{{ loop.index }}() { ctx_new cleanups[0]='' steps[0]='' + cleanups_captures[0]='' ret=0 {% for step in scenario.steps %} @@ -113,9 +116,11 @@ scenario_{{ loop.index }}() { echo " step: $step" cap_new + captures=() {% for part in step.parts %}{% if part.CapturedText is defined -%} name="$(decode_base64 '{{ part.CapturedText.name | base64 }}')" text="$(decode_base64 '{{ part.CapturedText.text | base64 }}')" + captures["$name"]="$text" cap_set "$name" "$text" {% endif -%} {% endfor -%} @@ -125,9 +130,9 @@ scenario_{{ loop.index }}() { if [ "$cleanup" != "" ] then {% raw %} - i=${#cleanups} - cleanups[$i]="$cleanup" - steps[$i]="$step" + cleanups+=("$cleanup") + steps+=("$step") + cleanups_captures+=("${captures[*]@A}") {% endraw %} fi else @@ -141,6 +146,13 @@ scenario_{{ loop.index }}() { do step="${steps[$i]}" func="${cleanups[$i]}" + eval "${cleanups_captures[$i]}" + cap_new + for name in "${!captures[@]}" + do + text="${captures["$name"]}" + cap_set "$name" "$text" + done echo " cleanup: $step" $func done |