#!/bin/csh


if ($#argv == 0) then
    goto help_lbl
    exit
endif

set dir = ""
foreach arg ($argv)
    @ counter++
    if ("$arg" == "-d") then
        @ counter++
        set dir = $argv[$counter]
        break
    endif
end

if ("$dir" == "") goto help_lbl

echo -n "Cleaning $dir directory... "

foreach arg ($argv)
    switch ($arg)
	case -f | --f19:
	    find $dir -name "*.f19" -delete
	    breaksw
	case -r | --root:
	    find $dir -name "*.root" -delete
	    breaksw
    endsw
end

find $dir -name "sched*" -delete
find $dir -name "*.out" -delete
find $dir -name "*.err" -delete
find $dir -name "*.session.xml" -delete

echo "Done"

exit

#########################
#### Help procedure #####
#########################
help_lbl:

echo "--== MrProper clean your folder ==--"
echo "   How to properly use MrProper:"
echo " 1) mrproper directory"
echo " 2) just turn'em on and watch how fast he "
echo "    cleans your directory from .root, .out and even .err files!"
