lib/Tools/update_cartouches
changeset 62445 91902961184c
parent 61579 634cd44bb1d3
child 62589 b5783412bfed
equal deleted inserted replaced
62444:94f457bea7c1 62445:91902961184c
     2 #
     2 #
     3 # Author: Makarius
     3 # Author: Makarius
     4 #
     4 #
     5 # DESCRIPTION: update theory syntax to use cartouches
     5 # DESCRIPTION: update theory syntax to use cartouches
     6 
     6 
       
     7 isabelle_admin_build jars || exit $?
     7 
     8 
     8 ## diagnostics
     9 "$ISABELLE_TOOL" java isabelle.Update_Cartouches "$@"
     9 
       
    10 PRG="$(basename "$0")"
       
    11 
       
    12 function usage()
       
    13 {
       
    14   echo
       
    15   echo "Usage: isabelle $PRG [FILES|DIRS...]"
       
    16   echo
       
    17   echo "  Options are:"
       
    18   echo "    -c           replace comment marker \"--\" by symbol \"\\<comment>\""
       
    19   echo "    -t           replace @{text} antiquotations within text tokens"
       
    20   echo
       
    21   echo "  Recursively find .thy files and update theory syntax to use cartouches"
       
    22   echo "  instead of old-style {* verbatim *} or \`alt_string\` tokens."
       
    23   echo
       
    24   echo "  Old versions of files are preserved by appending \"~~\"."
       
    25   echo
       
    26   exit 1
       
    27 }
       
    28 
       
    29 
       
    30 ## process command line
       
    31 
       
    32 # options
       
    33 
       
    34 COMMENT="false"
       
    35 TEXT="false"
       
    36 
       
    37 while getopts "ct" OPT
       
    38 do
       
    39   case "$OPT" in
       
    40     c)
       
    41       COMMENT="true"
       
    42       ;;
       
    43     t)
       
    44       TEXT="true"
       
    45       ;;
       
    46     \?)
       
    47       usage
       
    48       ;;
       
    49   esac
       
    50 done
       
    51 
       
    52 shift $(($OPTIND - 1))
       
    53 
       
    54 
       
    55 # args
       
    56 
       
    57 [ "$#" -eq 0 -o "$1" = "-?" ] && usage
       
    58 
       
    59 SPECS="$@"; shift "$#"
       
    60 
       
    61 
       
    62 ## main
       
    63 
       
    64 find $SPECS -name \*.thy -print0 | \
       
    65   xargs -0 "$ISABELLE_TOOL" java isabelle.Update_Cartouches "$COMMENT" "$TEXT"