buddylistgrapher

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 diff
     1.1 --- a/graph2.sh	Mon May 28 18:43:49 2007 +0200
     1.2 +++ b/graph2.sh	Mon May 28 20:03:27 2007 +0200
     1.3 @@ -7,9 +7,28 @@
     1.4  
     1.5  if [ $# -eq 1 ]; then
     1.6    if [ $1 = '--version' ] ; then
     1.7 -    echo 'Buddylistgrapher'
     1.8 -    echo 'shellscript edition'
     1.9 -    echo 'version 0.1'
    1.10 +    echo 'Buddylistgrapher (shell)'
    1.11 +    echo '========================'
    1.12 +    echo 'version 0.2'
    1.13 +    echo
    1.14 +    echo 'by Julian Forster (http://progmaschine.de.vu)'
    1.15 +    echo 'and Markus Schnalke (http://prog.marmaro.de)'
    1.16 +    exit 0
    1.17 +  elif [ $1 = '--help' ] ; then
    1.18 +    echo 'Buddylistgrapher (shell)'
    1.19 +    echo '========================'
    1.20 +    echo
    1.21 +    echo "usage: $0 <input.txt>"
    1.22 +    echo
    1.23 +    echo "The grapher generates output to stdout."
    1.24 +    echo "This output is the input for the graphviz tools."
    1.25 +    echo
    1.26 +    echo "You can use it like this:"
    1.27 +    echo "$0 input.txt | dot -Tpng > pic.png"
    1.28 +    echo
    1.29 +    echo "ToDo:"
    1.30 +    echo "The program was written for one specific kind of input data,"
    1.31 +    echo "so there is still some work to do to use it for general input."
    1.32      exit 0
    1.33    else
    1.34  
    1.35 @@ -19,22 +38,19 @@
    1.36      # extract all needed lines
    1.37      grep -e "Profil von:" -e "Nachricht schreiben" $1 > $file
    1.38  
    1.39 +
    1.40      # collect all profil names (we only want them as nodes)
    1.41      cat $file | while read line ; do
    1.42        echo -n "`echo $line | grep "Profil von:" | awk '{print " " $3 " "}'`" >> $file2
    1.43      done
    1.44      echo >> $file2
    1.45  
    1.46 -#cat $file2
    1.47 -#exit 
    1.48 -
    1.49  
    1.50      # output
    1.51      echo "digraph G {"
    1.52      
    1.53      cat $file | while read line ; do
    1.54 -      isProfil=`echo $line | grep "Profil von:"`
    1.55 -      if [ -n "$isProfil" ] ; then
    1.56 +      if [ -n "`echo $line | grep "Profil von:"`" ] ; then
    1.57          name=$(echo $line |  awk '{ print $3 }')
    1.58        else
    1.59          buddy=$(echo $line |  awk '{ print $3 }')
    1.60 @@ -46,7 +62,7 @@
    1.61  
    1.62      echo "}"
    1.63  
    1.64 -    #rm $file $file2
    1.65 +    rm $file $file2
    1.66      exit 0
    1.67  
    1.68    fi