moved getopts to Scala;
authorwenzelm
Sun, 28 Feb 2016 15:26:09 +0100
changeset 62449 1785cbadd226
parent 62448 5ec1d01089e3
child 62450 2154f709fc25
moved getopts to Scala;
lib/Tools/update_then
src/Pure/Tools/update_then.scala
--- a/lib/Tools/update_then	Sun Feb 28 15:21:08 2016 +0100
+++ b/lib/Tools/update_then	Sun Feb 28 15:26:09 2016 +0100
@@ -4,35 +4,6 @@
 #
 # DESCRIPTION: expand old Isar command conflations 'hence' and 'thus'
 
-
-## 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 expand old Isar command conflations:"
-  echo
-  echo "    hence  ~>  then have"
-  echo "    thus   ~>  then show"
-  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_Then
+"$ISABELLE_TOOL" java isabelle.Update_Then "$@"
--- a/src/Pure/Tools/update_then.scala	Sun Feb 28 15:21:08 2016 +0100
+++ b/src/Pure/Tools/update_then.scala	Sun Feb 28 15:26:09 2016 +0100
@@ -33,7 +33,24 @@
   def main(args: Array[String])
   {
     Command_Line.tool0 {
-      args.foreach(arg => update_then(Path.explode(arg)))
+      val getopts = Getopts(() => """
+Usage: isabelle update_then [FILES|DIRS...]
+
+  Recursively find .thy files and expand old Isar command conflations:
+
+    hence  ~>  then have
+    thus   ~>  then show
+
+  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_then(Path.explode(File.standard_path(file)))
     }
   }
 }