src/Pure/Tools/update_cartouches.scala
changeset 62445 91902961184c
parent 61579 634cd44bb1d3
child 62454 38c89353b349
equal deleted inserted replaced
62444:94f457bea7c1 62445:91902961184c
    85   /* command line entry point */
    85   /* command line entry point */
    86 
    86 
    87   def main(args: Array[String])
    87   def main(args: Array[String])
    88   {
    88   {
    89     Command_Line.tool0 {
    89     Command_Line.tool0 {
    90       args.toList match {
    90       var replace_comment = false
    91         case Properties.Value.Boolean(replace_comment) ::
    91       var replace_text = false
    92             Properties.Value.Boolean(replace_text) :: files =>
    92 
    93           files.foreach(file =>
    93       val getopts = Getopts(() => """
    94             update_cartouches(replace_comment, replace_text, Path.explode(file)))
    94 Usage: isabelle update_cartouches [FILES|DIRS...]
    95         case _ => error("Bad arguments:\n" + cat_lines(args))
    95 
    96       }
    96   Options are:
       
    97     -c           replace comment marker "--" by symbol "\<comment>"
       
    98     -t           replace @{text} antiquotations within text tokens
       
    99 
       
   100   Recursively find .thy files and update theory syntax to use cartouches
       
   101   instead of old-style {* verbatim *} or `alt_string` tokens.
       
   102 
       
   103   Old versions of files are preserved by appending "~~".
       
   104 """,
       
   105         "c" -> (_ => replace_comment = true),
       
   106         "t" -> (_ => replace_text = true))
       
   107 
       
   108       val specs = getopts(args)
       
   109       if (specs.isEmpty) getopts.usage()
       
   110 
       
   111       for {
       
   112         spec <- specs
       
   113         file <- File.find_files(Path.explode(spec).file, file => file.getName.endsWith(".thy"))
       
   114       } update_cartouches(replace_comment, replace_text, Path.explode(File.standard_path(file)))
    97     }
   115     }
    98   }
   116   }
    99 }
   117 }