#!/bin/bash
#---------------------------------------------------------------------
##
##=head1 SYNOPSIS
##
## vcast is front-end to cast to activate voyeurism in a
## separate xterm if possible.
##
##=head1 DESCRIPTION
##
## ...
##
##=head1 COPYRIGHT
##
## Original version Copyright 2001 by Kyle Sallee
## Additions/corrections Copyright 2002 by the Source Mage Team
##
##=head1 FUNCTIONS
##
##=over 4
##
#---------------------------------------------------------------------

process_parameters()  {

  while  [  -n  "$1"  ];  do

    if  echo  "" $1  |  grep  -q  "^ -";  then

      case  $1  in

                  --from)  export  SOURCE_CACHE="$2";       shift  2  ;;
                   --url)  export  BASE_URL="$2";           shift  2  ;;
              -n|--nofix)  NO_SUMMON="$1";  NO_GAZE="$1";   shift  1  ;;
                --silent)  NO_SUMMON="$1";  NO_GAZE="$1";   shift  1  ;;
                  --deps)  NO_SUMMON="$1";                  shift  1  ;;
                -f|--fix)  NO_SUMMON="$1";                  shift  1  ;;
                  --help)  HELP="$1";                       shift  1  ;;
                      -s)  NO_SUMMON="$1";                  shift  1  ;;
                       *)                                   shift  1  ;;
      esac

   else  shift
   fi

  done

}



strip_parameters()  {

  while  [  -n  "$1"  ];  do

    if  echo  "" $1  |  grep  -q  "^ -";  then

      case  $1  in
        --from)  shift 2  ;;
         --url)  shift 2  ;;
             *)  shift 1  ;;
      esac

    else  echo  $1;  shift
    fi

  done

}

process_parameters        $*
SPELLS=`strip_parameters  $*`

if  [  -z  "$*"     ]   ||
    [  -n  "$HELP"  ];  then
  cast;  exit  1
fi


if  [  -n  "$DISPLAY"  ];  then

  if  [  -z  "$NO_GAZE"  ];  then
    xterm  -bg  black                       \
           -fg  white                       \
           $XTERM_OPTIONS                   \
           -T   "gaze  voyeur  5  $SPELLS"  \
           -e   /bin/sh  -c  "gaze  voyeur  5  $SPELLS"  &
  fi

  if  [  -z  "$NO_SUMMON"  ];  then
    xterm  -bg  black             \
           -fg  white             \
           $XTERM_OPTIONS         \
           -T   "summon  $SPELLS"  \
           -e   /bin/sh  -c  "summon  $SPELLS"  &
  fi


fi

cast  $@


#---------------------------------------------------------------------
##=back
##
##=head1 LICENSE
##
## This software is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This software is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this software; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
##
#---------------------------------------------------------------------
