FEATURE: Allow templates to be nested.
authorGuo Xiang Tan <tgx_world@hotmail.com>
Thu, 4 Aug 2016 09:46:56 +0000 (17:46 +0800)
committerGuo Xiang Tan <tgx_world@hotmail.com>
Thu, 4 Aug 2016 09:53:47 +0000 (17:53 +0800)
launcher

index b897b42702d7ec0137305e6703cb3d9d0e19616b..50268d753d96be803f55076ea61e1ef90a05aa7e 100755 (executable)
--- a/launcher
+++ b/launcher
@@ -244,11 +244,31 @@ set_links() {
         "require 'yaml'; puts YAML.load(STDIN.readlines.join)['links'].map{|l| '--link ' << l['link']['name'] << ':' << l['link']['alias'] << ' '}.join"`
 }
 
-set_template_info() {
-
-    templates=`cat $config_file | $docker_path run $user_args --rm -i -a stdin -a stdout $image ruby -e \
+find_templates() {
+    local templates=`cat $1 | $docker_path run $user_args --rm -i -a stdin -a stdout $image ruby -e \
       "require 'yaml'; puts YAML.load(STDIN.readlines.join)['templates']"`
 
+    local arrTemplates=${templates// / }
+
+    if [ ! -z $templates ]; then
+      for template in "${arrTemplates[@]}"
+      do
+        local nested_templates=$(find_templates $template)
+
+        if [ ! -z "$nested_templates" ]; then
+          templates="$templates $nested_templates"
+        fi
+      done
+
+      echo $templates
+    else
+      echo ""
+    fi
+}
+
+set_template_info() {
+    templates=$(find_templates $config_file)
+
     arrTemplates=(${templates// / })
     config_data=$(cat $config_file)