|
1 /* Title: Pure/Tools/logo.scala |
|
2 Author: Makarius |
|
3 |
|
4 Create variants of the Isabelle logo (PDF). |
|
5 */ |
|
6 |
|
7 package isabelle |
|
8 |
|
9 |
|
10 object Logo |
|
11 { |
|
12 /* create logo */ |
|
13 |
|
14 def create_logo(logo_name: String, output_file: Path, quiet: Boolean = false): Unit = |
|
15 { |
|
16 Isabelle_System.with_tmp_file("logo", ext = "eps")(tmp_file => |
|
17 { |
|
18 val template = File.read(Path.explode("$ISABELLE_HOME/lib/logo/isabelle_any.eps")) |
|
19 File.write(tmp_file, template.replace("<any>", logo_name)) |
|
20 Isabelle_System.bash( |
|
21 "\"$ISABELLE_EPSTOPDF\" --filter < " + File.bash_path(tmp_file) + |
|
22 " > " + File.bash_path(output_file)).check |
|
23 if (!quiet) Output.writeln(output_file.expand.implode) |
|
24 }) |
|
25 } |
|
26 |
|
27 |
|
28 /* Isabelle tool wrapper */ |
|
29 |
|
30 val isabelle_tool = |
|
31 Isabelle_Tool("logo", "create variants of the Isabelle logo (PDF)", Scala_Project.here, args => |
|
32 { |
|
33 var output: Option[Path] = None |
|
34 var quiet = false |
|
35 |
|
36 val getopts = Getopts(""" |
|
37 Usage: isabelle logo [OPTIONS] [NAME] |
|
38 |
|
39 Options are: |
|
40 -o FILE alternative output file |
|
41 -q quiet mode |
|
42 |
|
43 Create variant NAME of the Isabelle logo as "isabelle_name.pdf". |
|
44 """, |
|
45 "o:" -> (arg => output = Some(Path.explode(arg))), |
|
46 "q" -> (_ => quiet = true)) |
|
47 |
|
48 val more_args = getopts(args) |
|
49 val (logo_name, output_file) = |
|
50 more_args match { |
|
51 case Nil => ("", Path.explode("isabelle").pdf) |
|
52 case List(a) => (a, output.getOrElse(Path.explode("isabelle_" + Word.lowercase(a)).pdf)) |
|
53 case _ => getopts.usage() |
|
54 } |
|
55 |
|
56 create_logo(logo_name, output_file, quiet = quiet) |
|
57 }) |
|
58 } |