#! /bin/csh -f
# Last edited on 2008-05-02 11:23:04 by stolfi

set PROG_NAME = "$0"
set PROG_DESC = "bla bla bla."
set PROG_HELP = ( \
  ''"${PROG_NAME}"' \\' \
  '\n    [ -op0 ] \\' \
  '\n    [ -op2 {ARG1} {ARG2} ] {NAME1} {NAME2} {FILE..} \\' \
  '\n    [ -help ] [ -info ]' \
)
set PROG_INFO = ( \
  'NAME' \
  '\n  '"${PROG_NAME}"' - '"${PROG_DESC}"'.' \
  '\n' \
  '\nSYNOPSIS' \
  '\n  '"${PROG_HELP}"'' \
  '\n' \
  '\nDESCRIPTION' \
  '\n  Bla bla bla bla bla files {FILE..}, bla' \
  '\n  bla bla bla.  Bla bla bla, bla bla bla' \
  '\n  bla bla bla bla bla:' \
  '\n' \
  '\n    {ARG1}--{ARG2}.txt  bla bla bla.' \
  '\n    {NAME1}.bla         bla bla "{NAME1}.c" bla "{NAME1}.h".' \
  '\n    {NAME2}-{NN}.bla    bla bla bla where {NN} bla bla.' \
  '\n    {FILEi}             bla bla bla {FILES...}' \
  '\n' \
  '\nOPTIONS' \
  '\n  -op0' \
  '\n    If present, bla bla bla.  If absent, bla' \
  '\n    bla bla bla.' \
  '\n' \
  '\n  -op2 {ARG1} {ARG2}' \
  '\n    If present, bla bla bla.  If absent, bla' \
  '\n    bla bla bla {ARG1} is "BLA" bla {ARG2} is "BLA".' \
  '\n' \
  '\nSEE ALSO' \
  '\n  find-all-sources(1)' \
  '\nAUTHOR' \
  '\n  Created 2008-05-02 by Jorge Stolfi, Unicamp' \
)

# ----------------------------------------------------------------------
# INTERNAL OPTIONS

set bla_dir = "bla/bla"
set bla_ini = 00
set bla_fin = 20

# ----------------------------------------------------------------------
# COMMAND LINE PARSING

# Parse command line switches (keyword parameters): 
set bla_op0 = 0
set bla_arg1 = 0
set bla_arg2 = 0
set bla_files = ( )
while ( ( $#argv > 0 ) && ( "/$1" =~ /-* ) )
  if ( ( $#argv >= 1 ) && ( "/$1" == "/-op0" ) ) then
    shift; set bla_op0 = 1;
  else if ( ( $#argv >= 3 ) && ( "/$1" == "/-op2" ) ) then
    shift; 
    set bla_arg1 = "$1"; shift 
    set bla_arg2 = "$1"; shift
    set bla_files = ( "${bla_arg1}.bla" ${bla_files} )
  else if ( ( $#argv >= 1 ) && ( "/$1" == "/-help" ) ) then
    shift; printf "usage:\n  ${PROG_HELP}\n"; exit 0
  else if ( ( $#argv >= 1 ) && ( "/$1" == "/-info" ) ) then
    shift; printf "${PROG_INFO}"; exit 0
  else
    echo "unknown option $1";
    printf "usage:\n  ${PROG_HELP}\n"; exit 1
  endif
end

# Parse remaining command line arguments (positional parameters):
if ( $#argv < 2 ) then
  printf "usage:\n  ${PROG_HELP}\n"; exit 1
endif
set bla_name1 = "$1"; shift
set bla_name2 = "$1"; shift
set bla_files = ( ${bla_files} $* )

# Do it:
echo "bla bla bla ${bla_op0} ${bla_arg1} ${bla_arg2} ${bla_name1} ${bla_name2} ( ${bla_files} )"

exit 0
