#!/bin/sh

echo "--------------------------"
echo "panji Tcl Tools 1.0    "
echo "by panjiSoft Team 2004 "
echo "--------------------------"
echo ""

#if test $1 = "-l"
#then
#  echo "Daftar tcl pada $2"
#  grep "source scripts" $2
#  echo ""
#  exit
#fi

if test $# -lt 3 
then
  echo "Cara Penggunaan :"
  echo ""
  echo "   ./tcl -[t] Nama_Config_File [Nama_File_tcl]"
  echo ""
  echo "   -t : tambahkan file tcl ke config file"
  echo ""
  echo "   contoh  : ./tcl -t configku.txt seen.tcl"
  echo "   catatan : file tcl yg akan ditambahkan harus berada di directory scripts"
  echo ""
  exit
fi

if ! test -s $2
then
  echo "Kesalahan : config file $2 tidak ditemukan !!!"
  echo ""
  exit
fi

if test $1 = "-t"
then

  ada=`grep "source scripts/$3" $2`
  if test -n "$ada"
  then
    echo "Kesalahan : $3 sudah terdapat pada $2"
    echo ""
    exit
  fi
  
  if ! test -s scripts/$3
  then
    echo "Kesalahan : file $3 tidak ditemukan pada directory scripts"
    echo ""
    exit
  else 
    echo "source scripts/$3" >> $2
    echo "$3 telah ditambahkan pada $2"
  fi
fi

echo ""

