lib/Tools/keywords
author wenzelm
Sat, 10 Jan 2009 13:10:07 +0100
changeset 29427 7ba952481e29
parent 29143 72c960b2b83e
child 33684 29d8aaeb56e5
permissions -rwxr-xr-x
excursion: commit_exit internally -- checkpoints are fully persistent now; excursion: do not force intermediate result states yet -- great performance improvement;

#!/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 "    -t TARGET    target tool (default: emacs)"
  echo
  echo "  Generate outer syntax keyword files from (compressed) session LOGS."
  echo
  exit 1
}


## process command line

# options

KEYWORDS_NAME=""
TARGET_TOOL="emacs"

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

shift $(($OPTIND - 1))


# args

LOGS="$@"; shift "$#"


## main

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

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