#/bin/sh

# There are 2 main cases: generate all the usual classes, and
# generate the classes for one specified list type.  In both,
# there is an optional base-directory 1st arg.  If it is present,
# there will be 1 or 3 args in total.  Once it is removed,
# there will be 0 or 2.

# Optional base directory is first
if [ "$#" -eq 1 -o "$#" -eq 3 ]
then
  base_spec=":base-directory \"$1\""
  shift
else
  base_spec=""
fi

# Now handle remaining args
if [ "$#" -eq 0 ]
then
  cmucl << commands
  (load "gen/util/util-setup.lsp")
  (load-system 'listof-gen)
  (listof:generate $base_spec)
  (quit)
commands
elif [ "$#" -eq 2 ]
then
  package=$1
  class=$2
  cmucl << commands
  (load "gen/util/util-setup.lsp")
  (load-system 'listof-gen)
  (listof:generate $base_spec :package "$package" :element-class "$class")
  (quit)
commands
else
  echo "usage: gen/gen-listofs [base_dir] [package element_class]"
fi
