]> gitweb.fluxo.info Git - simplepkg.git/commitdiff
templatepkg: --list improved
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Fri, 6 Apr 2007 01:00:12 +0000 (01:00 +0000)
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Fri, 6 Apr 2007 01:00:12 +0000 (01:00 +0000)
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@274 04377dda-e619-0410-9926-eae83683ac58

trunk/src/templatepkg

index 3b5c283c625cc168295c2b8ffe067bd3218a67aa..4521fef2b14c4d3eeee3cf32e718eafd84472814 100755 (executable)
@@ -526,20 +526,42 @@ function template_list {
   # list templates
   # usage: template_list [template_name]
 
-  local list
+  local list basedir template
 
-  # TODO: checar se ha /
+  if echo $1 | grep -q "/"; then
 
-  list="`ls $BASE_CONF/defaults/templates/$1 2> /dev/null`"
-  if [ "$?" == "0" ]; then
-    list="`echo $list | xargs`"
-    echo "Default templates: $list"
-  fi
+    template="`echo $1 | cut -d "/" -f 1`"
+
+    if [ -e "$BASE_CONF/defaults/templates/$1" ]; then
+      list="`ls $BASE_CONF/defaults/templates/$1 2> /dev/null`"
+      if [ "$?" == "0" ]; then
+        list="`echo $list | xargs`"
+        echo "In the default template $template: $list"
+      fi
+    fi
+
+    if [ -e "$BASE_CONF/templates/$1" ]; then
+      list="`ls $BASE_CONF/templates/$1 2> /dev/null`"
+      if [ "$?" == "0" ]; then
+        list="`echo $list | xargs`"
+        echo "In the custom template $template: $list"
+      fi      
+    fi
+
+  else
+
+    list="`ls $BASE_CONF/defaults/templates/$1 2> /dev/null`"
+    if [ "$?" == "0" ]; then
+      list="`echo $list | xargs`"
+      echo "Default templates: $list"
+    fi
+
+    list="`ls $BASE_CONF/templates/$1 2> /dev/null`"
+    if [ "$?" == "0" ]; then
+      list="`echo $list | xargs`"
+      echo "Custom templates: $list"
+    fi
 
-  list="`ls $BASE_CONF/templates/$1 2> /dev/null`"
-  if [ "$?" == "0" ]; then
-    list="`echo $list | xargs`"
-    echo "Custom templates: $list"
   fi
 
 }