# HG changeset patch # User wenzelm # Date 1456670090 -3600 # Node ID 2154f709fc25861f059d493ee77c46742bd80b28 # Parent 1785cbadd22695428ba469d52e380e8c078ef643 moved getopts to Scala; diff -r 1785cbadd226 -r 2154f709fc25 lib/Tools/update_theorems --- a/lib/Tools/update_theorems Sun Feb 28 15:26:09 2016 +0100 +++ b/lib/Tools/update_theorems Sun Feb 28 15:34:50 2016 +0100 @@ -4,37 +4,6 @@ # # DESCRIPTION: update toplevel theorem keywords - -## diagnostics - -PRG="$(basename "$0")" +isabelle_admin_build jars || exit $? -function usage() -{ - echo - echo "Usage: isabelle $PRG [FILES|DIRS...]" - echo - echo " Recursively find .thy files and update toplevel theorem keywords:" - echo - echo " theorems ~> lemmas" - echo " schematic_theorem ~> schematic_goal" - echo " schematic_lemma ~> schematic_goal" - echo " schematic_corollary ~> schematic_goal" - echo - echo " Old versions of files are preserved by appending \"~~\"." - echo - exit 1 -} - - -## process command line - -[ "$#" -eq 0 -o "$1" = "-?" ] && usage - -SPECS="$@"; shift "$#" - - -## main - -find $SPECS -name \*.thy -print0 | \ - xargs -0 "$ISABELLE_TOOL" java isabelle.Update_Theorems +"$ISABELLE_TOOL" java isabelle.Update_Theorems "$@" diff -r 1785cbadd226 -r 2154f709fc25 src/Pure/Tools/update_theorems.scala --- a/src/Pure/Tools/update_theorems.scala Sun Feb 28 15:26:09 2016 +0100 +++ b/src/Pure/Tools/update_theorems.scala Sun Feb 28 15:34:50 2016 +0100 @@ -34,7 +34,26 @@ def main(args: Array[String]) { Command_Line.tool0 { - args.foreach(arg => update_theorems(Path.explode(arg))) + val getopts = Getopts(() => """ +Usage: isabelle update_theorems [FILES|DIRS...] + + Recursively find .thy files and update toplevel theorem keywords: + + theorems ~> lemmas + schematic_theorem ~> schematic_goal + schematic_lemma ~> schematic_goal + schematic_corollary ~> schematic_goal + + Old versions of files are preserved by appending "~~". +""") + + val specs = getopts(args) + if (specs.isEmpty) getopts.usage() + + for { + spec <- specs + file <- File.find_files(Path.explode(spec).file, file => file.getName.endsWith(".thy")) + } update_theorems(Path.explode(File.standard_path(file))) } } }