lib/Tools/keywords
author hoelzl
Mon, 06 Dec 2010 19:54:48 +0100
changeset 41024 ba961a606c67
parent 35022 c844b93dd147
child 52439 4cf3f6153eb8
permissions -rwxr-xr-x
move coercions to appropriate places

#!/usr/bin/env bash
#
# Author: Makarius
#
# DESCRIPTION: generate outer syntax keyword files from session logs


## diagnostics

PRG="$(basename "$0")"

function usage()
{
  echo
  echo "Usage: isabelle $PRG [OPTIONS] [LOGS ...]"
  echo
  echo "  Options are:"
  echo "    -k NAME      specific name of keywords collection (default: empty)"
  echo
  echo "  Generate outer syntax keyword files from (compressed) session LOGS."
  echo "  Targets Emacs Proof General."
  echo
  exit 1
}


## process command line

# options

KEYWORDS_NAME=""

while getopts "k:" OPT
do
  case "$OPT" in
    k)
      KEYWORDS_NAME="$OPTARG"
      ;;
    \?)
      usage
      ;;
  esac
done

shift $(($OPTIND - 1))


## main

SESSIONS=""
for LOG in "$@"
do
  NAME="$(basename "$LOG" .gz)"
  if [ -z "$SESSIONS" ]; then
    SESSIONS="$NAME"
  else
    SESSIONS="$SESSIONS + $NAME"
  fi
done

for LOG in "$@"
do
  if [ "${LOG%.gz}" = "$LOG" ]; then
    cat "$LOG"
  else
    gzip -dc "$LOG"
  fi
  echo
done | "$ISABELLE_HOME/lib/scripts/keywords" "$KEYWORDS_NAME" "$SESSIONS"