lib/Tools/update_cartouches
author paulson <lp15@cam.ac.uk>
Thu, 25 Feb 2016 13:58:48 +0000
changeset 62408 86f27b264d3d
parent 61579 634cd44bb1d3
child 62445 91902961184c
permissions -rwxr-xr-x
Conformal_mappings: a big development in complex analysis (+ some lemmas)

#!/usr/bin/env bash
#
# Author: Makarius
#
# DESCRIPTION: update theory syntax to use cartouches


## diagnostics

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

function usage()
{
  echo
  echo "Usage: isabelle $PRG [FILES|DIRS...]"
  echo
  echo "  Options are:"
  echo "    -c           replace comment marker \"--\" by symbol \"\\<comment>\""
  echo "    -t           replace @{text} antiquotations within text tokens"
  echo
  echo "  Recursively find .thy files and update theory syntax to use cartouches"
  echo "  instead of old-style {* verbatim *} or \`alt_string\` tokens."
  echo
  echo "  Old versions of files are preserved by appending \"~~\"."
  echo
  exit 1
}


## process command line

# options

COMMENT="false"
TEXT="false"

while getopts "ct" OPT
do
  case "$OPT" in
    c)
      COMMENT="true"
      ;;
    t)
      TEXT="true"
      ;;
    \?)
      usage
      ;;
  esac
done

shift $(($OPTIND - 1))


# args

[ "$#" -eq 0 -o "$1" = "-?" ] && usage

SPECS="$@"; shift "$#"


## main

find $SPECS -name \*.thy -print0 | \
  xargs -0 "$ISABELLE_TOOL" java isabelle.Update_Cartouches "$COMMENT" "$TEXT"