#!/bin/sh
# Copyright (c)2002 Joe Wreschnig <piman@debian.org>
# Under the terms of the GNU GPL v2.
# A Feta plugin to search Feta's command help

OPTS=`getopt -n configure -o V,q,t,y -- $@`
if [ $? != 0 ] ; then exit 1; fi
eval set -- "$OPTS"
VERBOSE=0

while true ; do
 case "$1" in
  -V) VERBOSE=1; shift;;
  -t|-q|-y) shift;;
  --) shift; break;;
 esac
done

if [ $# -eq 0 ]; then
 echo "E: You must provide at least one search term."
 exit 1
fi

for I in $*; do for J in /usr/share/feta/help/* /usr/local/share/feta/help/*; do
 if grep $I $J > /dev/null 2> /dev/null; then
  /bin/echo -e "$J:  Found '$I'" | sed 's!^.*/!!'
  if [ $VERBOSE -eq 1 ]; then grep $I $J; echo; fi
 fi done done
