src/Pure/Tools/mkroot.scala
author wenzelm
Sat, 25 Nov 2023 20:41:18 +0100
changeset 79064 a54be9630ef8
parent 76558 d6a2a8bc40e1
permissions -rw-r--r--
clarified modules;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
67041
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
     1
/*  Title:      Pure/Tools/mkroot.scala
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
     3
76556
c7f3e94fce7b tuned messages and options;
wenzelm
parents: 75394
diff changeset
     4
Create session root directory.
67041
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
     5
*/
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
     6
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
     7
package isabelle
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
     8
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
     9
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74434
diff changeset
    10
object Mkroot {
67041
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    11
  /** mkroot **/
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    12
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    13
  def root_name(name: String): String =
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    14
    Token.quote_name(Sessions.root_syntax.keywords, name)
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    15
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    16
  def latex_name(name: String): String =
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    17
    (for (c <- name.iterator if c != '\\')
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    18
     yield if (c == '_') '-' else c).mkString
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    19
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    20
  def mkroot(
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    21
    session_name: String = "",
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    22
    session_dir: Path = Path.current,
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    23
    session_parent: String = "",
67069
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
    24
    init_repos: Boolean = false,
67041
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    25
    title: String = "",
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    26
    author: String = "",
76556
c7f3e94fce7b tuned messages and options;
wenzelm
parents: 75394
diff changeset
    27
    quiet: Boolean = false,
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74434
diff changeset
    28
    progress: Progress = new Progress
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74434
diff changeset
    29
  ): Unit = {
72375
e48d93811ed7 clarified signature;
wenzelm
parents: 71726
diff changeset
    30
    Isabelle_System.make_directory(session_dir)
67041
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    31
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    32
    val name = proper_string(session_name) getOrElse session_dir.absolute_file.getName
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    33
    val parent = proper_string(session_parent) getOrElse Isabelle_System.getenv("ISABELLE_LOGIC")
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    34
72832
03803bbfdca3 tuned signature;
wenzelm
parents: 72763
diff changeset
    35
    val root_path = session_dir + Sessions.ROOT
67041
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    36
    if (root_path.file.exists) error("Cannot overwrite existing " + root_path)
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    37
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    38
    val document_path = session_dir + Path.explode("document")
67042
677cab7c2b85 adapted to changed ROOT syntax (see 13857f49d215);
wenzelm
parents: 67041
diff changeset
    39
    if (document_path.file.exists) error("Cannot overwrite existing " + document_path)
67041
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    40
67069
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
    41
    val root_tex = session_dir + Path.explode("document/root.tex")
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
    42
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
    43
76557
6dc213e7f664 tuned message;
wenzelm
parents: 76556
diff changeset
    44
    progress.echo(
6dc213e7f664 tuned message;
wenzelm
parents: 76556
diff changeset
    45
      (if (quiet) "" else "\n") +
76558
d6a2a8bc40e1 tuned messages;
wenzelm
parents: 76557
diff changeset
    46
      "Initializing session " + quote(name) + " in " + session_dir.absolute)
67041
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    47
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    48
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    49
    /* ROOT */
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    50
76556
c7f3e94fce7b tuned messages and options;
wenzelm
parents: 75394
diff changeset
    51
    progress.echo_if(!quiet, "  creating " + root_path)
67041
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    52
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    53
    File.write(root_path,
67042
677cab7c2b85 adapted to changed ROOT syntax (see 13857f49d215);
wenzelm
parents: 67041
diff changeset
    54
      "session " + root_name(name) + " = " + root_name(parent) + """ +
67041
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    55
  options [document = pdf, document_output = "output"]
67042
677cab7c2b85 adapted to changed ROOT syntax (see 13857f49d215);
wenzelm
parents: 67041
diff changeset
    56
(*theories [document = false]
677cab7c2b85 adapted to changed ROOT syntax (see 13857f49d215);
wenzelm
parents: 67041
diff changeset
    57
    A
677cab7c2b85 adapted to changed ROOT syntax (see 13857f49d215);
wenzelm
parents: 67041
diff changeset
    58
    B
67041
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    59
  theories
67042
677cab7c2b85 adapted to changed ROOT syntax (see 13857f49d215);
wenzelm
parents: 67041
diff changeset
    60
    C
677cab7c2b85 adapted to changed ROOT syntax (see 13857f49d215);
wenzelm
parents: 67041
diff changeset
    61
    D*)
67041
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    62
  document_files
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    63
    "root.tex"
67042
677cab7c2b85 adapted to changed ROOT syntax (see 13857f49d215);
wenzelm
parents: 67041
diff changeset
    64
""")
67041
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    65
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    66
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    67
    /* document directory */
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    68
67042
677cab7c2b85 adapted to changed ROOT syntax (see 13857f49d215);
wenzelm
parents: 67041
diff changeset
    69
    {
76556
c7f3e94fce7b tuned messages and options;
wenzelm
parents: 75394
diff changeset
    70
      progress.echo_if(!quiet, "  creating " + root_tex)
67041
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    71
72375
e48d93811ed7 clarified signature;
wenzelm
parents: 71726
diff changeset
    72
      Isabelle_System.make_directory(root_tex.dir)
67041
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    73
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    74
      File.write(root_tex,
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    75
"""\documentclass[11pt,a4paper]{article}
73404
299f6a8faccc proper type-setting of cartouches (requires T1);
wenzelm
parents: 73340
diff changeset
    76
\""" + """usepackage[T1]{fontenc}
67041
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    77
\""" + """usepackage{isabelle,isabellesym}
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    78
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    79
% further packages required for unusual symbols (see also
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    80
% isabellesym.sty), use only when needed
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    81
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    82
%\""" + """usepackage{amssymb}
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    83
  %for \<leadsto>, \<box>, \<diamond>, \<sqsupset>, \<mho>, \<Join>,
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    84
  %\<lhd>, \<lesssim>, \<greatersim>, \<lessapprox>, \<greaterapprox>,
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    85
  %\<triangleq>, \<yen>, \<lozenge>
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    86
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    87
%\""" + """usepackage{eurosym}
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    88
  %for \<euro>
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    89
74434
7d6c7c86d88b clarified comments;
wenzelm
parents: 74433
diff changeset
    90
%\""" + """usepackage[only,bigsqcap,bigparallel,fatsemi,interleave,sslash]{stmaryrd}
7d6c7c86d88b clarified comments;
wenzelm
parents: 74433
diff changeset
    91
  %for \<Sqinter>, \<Parallel>, \<Zsemi>, \<Parallel>, \<sslash>
67041
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    92
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    93
%\""" + """usepackage{eufrak}
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    94
  %for \<AA> ... \<ZZ>, \<aa> ... \<zz> (also included in amssymb)
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    95
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    96
%\""" + """usepackage{textcomp}
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    97
  %for \<onequarter>, \<onehalf>, \<threequarters>, \<degree>, \<cent>,
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    98
  %\<currency>
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
    99
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   100
% this should be the last package used
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   101
\""" + """usepackage{pdfsetup}
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   102
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   103
% urls in roman style, theory text in math-similar italics
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   104
\""" + """urlstyle{rm}
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   105
\isabellestyle{it}
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   106
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   107
% for uniform font size
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   108
%\renewcommand{\isastyle}{\isastyleminor}
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   109
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   110
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   111
\begin{document}
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   112
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   113
\title{""" + (proper_string(title) getOrElse latex_name(name)) + """}
67043
848672fcaee5 more options for "isabelle mkroot";
wenzelm
parents: 67042
diff changeset
   114
\author{""" + (proper_string(author) getOrElse latex_name(System.getProperty("user.name"))) + """}
67041
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   115
\maketitle
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   116
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   117
\tableofcontents
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   118
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   119
% sane default for proof documents
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   120
\parindent 0pt\parskip 0.5ex
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   121
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   122
% generated text of all theories
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   123
\input{session}
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   124
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   125
% optional bibliography
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   126
%\bibliographystyle{abbrv}
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   127
%\bibliography{root}
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   128
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   129
\end{document}
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   130
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   131
%%% Local Variables:
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   132
%%% mode: latex
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   133
%%% TeX-master: t
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   134
%%% End:
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   135
""")
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   136
    }
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   137
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   138
67069
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
   139
    /* Mercurial repository */
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
   140
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
   141
    if (init_repos) {
76558
d6a2a8bc40e1 tuned messages;
wenzelm
parents: 76557
diff changeset
   142
      progress.echo(
d6a2a8bc40e1 tuned messages;
wenzelm
parents: 76557
diff changeset
   143
        (if (quiet) "" else "\n") +
d6a2a8bc40e1 tuned messages;
wenzelm
parents: 76557
diff changeset
   144
        "Initializing Mercurial repository " + session_dir.absolute)
67069
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
   145
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
   146
      val hg = Mercurial.init_repository(session_dir)
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
   147
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
   148
      val hg_ignore = session_dir + Path.explode(".hgignore")
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
   149
      File.write(hg_ignore,
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
   150
"""syntax: glob
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
   151
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
   152
*~
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
   153
*.marks
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
   154
*.orig
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
   155
*.rej
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
   156
.DS_Store
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
   157
.swp
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
   158
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
   159
syntax: regexp
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
   160
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
   161
^output/
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
   162
""")
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
   163
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
   164
      hg.add(List(root_path, root_tex, hg_ignore))
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
   165
    }
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
   166
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
   167
67041
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   168
    /* notes */
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   169
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   170
    {
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   171
      val print_dir = session_dir.implode
76556
c7f3e94fce7b tuned messages and options;
wenzelm
parents: 75394
diff changeset
   172
      progress.echo_if(!quiet, """
67041
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   173
Now use the following command line to build the session:
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   174
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   175
  isabelle build -D """ +
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   176
        (if (Bash.string(print_dir) == print_dir) print_dir else quote(print_dir)) + "\n")
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   177
    }
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   178
  }
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   179
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   180
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   181
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   182
  /** Isabelle tool wrapper **/
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   183
76556
c7f3e94fce7b tuned messages and options;
wenzelm
parents: 75394
diff changeset
   184
  val isabelle_tool = Isabelle_Tool("mkroot", "create session root directory",
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74434
diff changeset
   185
    Scala_Project.here,
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   186
    { args =>
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   187
      var author = ""
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   188
      var init_repos = false
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   189
      var title = ""
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   190
      var session_name = ""
76556
c7f3e94fce7b tuned messages and options;
wenzelm
parents: 75394
diff changeset
   191
      var quiet = false
67041
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   192
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   193
      val getopts = Getopts("""
67043
848672fcaee5 more options for "isabelle mkroot";
wenzelm
parents: 67042
diff changeset
   194
Usage: isabelle mkroot [OPTIONS] [DIRECTORY]
67041
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   195
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   196
  Options are:
67043
848672fcaee5 more options for "isabelle mkroot";
wenzelm
parents: 67042
diff changeset
   197
    -A LATEX     provide author in LaTeX notation (default: user name)
67069
f11486d31586 init Mercurial repository for the generated session files;
wenzelm
parents: 67043
diff changeset
   198
    -I           init Mercurial repository and add generated files
67043
848672fcaee5 more options for "isabelle mkroot";
wenzelm
parents: 67042
diff changeset
   199
    -T LATEX     provide title in LaTeX notation (default: session name)
848672fcaee5 more options for "isabelle mkroot";
wenzelm
parents: 67042
diff changeset
   200
    -n NAME      alternative session name (default: directory base name)
76556
c7f3e94fce7b tuned messages and options;
wenzelm
parents: 75394
diff changeset
   201
    -q           quiet mode: less verbosity
67041
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   202
76556
c7f3e94fce7b tuned messages and options;
wenzelm
parents: 75394
diff changeset
   203
  Create session root directory (default: current directory).
67041
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   204
""",
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   205
        "A:" -> (arg => author = arg),
76556
c7f3e94fce7b tuned messages and options;
wenzelm
parents: 75394
diff changeset
   206
        "I" -> (_ => init_repos = true),
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   207
        "T:" -> (arg => title = arg),
76556
c7f3e94fce7b tuned messages and options;
wenzelm
parents: 75394
diff changeset
   208
        "n:" -> (arg => session_name = arg),
c7f3e94fce7b tuned messages and options;
wenzelm
parents: 75394
diff changeset
   209
        "q" -> (_ => quiet = true))
67041
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   210
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   211
      val more_args = getopts(args)
67041
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   212
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   213
      val session_dir =
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   214
        more_args match {
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   215
          case Nil => Path.current
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   216
          case List(dir) => Path.explode(dir)
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   217
          case _ => getopts.usage()
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   218
        }
67041
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   219
76556
c7f3e94fce7b tuned messages and options;
wenzelm
parents: 75394
diff changeset
   220
      val progress = new Console_Progress
c7f3e94fce7b tuned messages and options;
wenzelm
parents: 75394
diff changeset
   221
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   222
      mkroot(session_name = session_name, session_dir = session_dir, init_repos = init_repos,
76556
c7f3e94fce7b tuned messages and options;
wenzelm
parents: 75394
diff changeset
   223
        author = author, title = title, quiet = quiet, progress = progress)
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   224
    })
67041
f8b0367046bd converted to Isabelle/Scala;
wenzelm
parents:
diff changeset
   225
}