diff graph2.sh @ 2:6c327ae23d2c

added --help to shell edition some cleanups
author meillo@marmaro.de
date Mon, 28 May 2007 20:03:27 +0200
parents 21d9547ef242
children
line wrap: on
line diff
--- a/graph2.sh	Mon May 28 18:43:49 2007 +0200
+++ b/graph2.sh	Mon May 28 20:03:27 2007 +0200
@@ -7,9 +7,28 @@
 
 if [ $# -eq 1 ]; then
   if [ $1 = '--version' ] ; then
-    echo 'Buddylistgrapher'
-    echo 'shellscript edition'
-    echo 'version 0.1'
+    echo 'Buddylistgrapher (shell)'
+    echo '========================'
+    echo 'version 0.2'
+    echo
+    echo 'by Julian Forster (http://progmaschine.de.vu)'
+    echo 'and Markus Schnalke (http://prog.marmaro.de)'
+    exit 0
+  elif [ $1 = '--help' ] ; then
+    echo 'Buddylistgrapher (shell)'
+    echo '========================'
+    echo
+    echo "usage: $0 <input.txt>"
+    echo
+    echo "The grapher generates output to stdout."
+    echo "This output is the input for the graphviz tools."
+    echo
+    echo "You can use it like this:"
+    echo "$0 input.txt | dot -Tpng > pic.png"
+    echo
+    echo "ToDo:"
+    echo "The program was written for one specific kind of input data,"
+    echo "so there is still some work to do to use it for general input."
     exit 0
   else
 
@@ -19,22 +38,19 @@
     # extract all needed lines
     grep -e "Profil von:" -e "Nachricht schreiben" $1 > $file
 
+
     # collect all profil names (we only want them as nodes)
     cat $file | while read line ; do
       echo -n "`echo $line | grep "Profil von:" | awk '{print " " $3 " "}'`" >> $file2
     done
     echo >> $file2
 
-#cat $file2
-#exit 
-
 
     # output
     echo "digraph G {"
     
     cat $file | while read line ; do
-      isProfil=`echo $line | grep "Profil von:"`
-      if [ -n "$isProfil" ] ; then
+      if [ -n "`echo $line | grep "Profil von:"`" ] ; then
         name=$(echo $line |  awk '{ print $3 }')
       else
         buddy=$(echo $line |  awk '{ print $3 }')
@@ -46,7 +62,7 @@
 
     echo "}"
 
-    #rm $file $file2
+    rm $file $file2
     exit 0
 
   fi