summaryrefslogtreecommitdiff
path: root/docs/man/src/man/man1/scalascript.scala
blob: 1ab8b1994ff79b23036b133fa5beb3dbc76257da (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/* NSC -- new Scala compiler
 * Copyright 2005-2006 LAMP/EPFL
 * @author Stephane Micheloud
 */
//$Id: $

package man.man1

object scalascript extends Command {
  import ManPage._

  protected val cn = new Error().getStackTrace()(0).getClassName()

  val name = Section("NAME",

    MBold(command) & " " & NDash & " Script runner for the " &
    Link("Scala 2", "http://scala.epfl.ch/") & " language")

  val synopsis = Section("SYNOPSIS",

   CmdLine(" [ " & Argument("compiler args...") & " - ] " &
           Argument("scriptfile") & " [ " & Argument("script args...") & " ]"))

  val parameters = Section("PARAMETERS",

    DefinitionList(
      Definition(
        Mono(Argument("compiler args")),
        "Compiler arguments, exactly as for " & MBold("scalac") & ". " &
        "The compiler arguments, if present, must be terminated by a " &
        "bare hyphen."),
      Definition(
        Mono(Argument("scriptfile")),
        "One source file to be interpreted."),
      Definition(
        Mono(Argument("script args")),
        "Arguments to be passed to the script. They will be available " &
        "via the " & Mono("argv") & " variable.")))

  val description = Section("DESCRIPTION",

    "The " & MBold(command) & " tool supports writing script files " &
    "in Scala. To write a Scala script on Unix, start the file with the " &
    "following header:",

    CodeSample(
      "#!/bin/sh\n" +
      "exec scalascript \"$0\" \"$@\"\n" +
      "!#"),

    "To write a Scala script as a Microsoft Windows batch file, start " &
    "the " & Mono(".bat") & " file with the following header:",

    CodeSample(
      "::#!\n" +
      "@echo off\n" +
      "call scalascript %0 %*\n" +
      "goto :eof\n" +
      "::!#"))

  val examples = Section("EXAMPLES",

    "Here is a complete Scala script for Unix that prints out a " &
    "friendly greeting followed by all of the script's arguments:",

    CodeSample(
      "#!/bin/sh\n" +
      "exec scalascript \"$0\" \"$@\"\n" +
      "!#\n" +
      "Console.println(\"Hello, world!\")\n" +
      "argv.toList foreach Console.println"))

  override val authors = Section("AUTHOR",

    "Written by Lex Spoon.")

  val seeAlso = Section("SEE ALSO",

    Link(Bold("scala") & "(1)", "scala.html") & ", " &
    Link(Bold("scalac") & "(1)", "scalac.html") & ", " &
    Link(Bold("scaladoc") & "(1)", "scaladoc.html") & ", " &
    Link(Bold("scalaint") & "(1)", "scalaint.html") & ", " &
    Link(Bold("scalap") & "(1)", "scalap.html"))

  def manpage = new Document {
    title = command
    date = "April 29, 2005"
    author = "Stephane Micheloud"
    version = "0.1"
    sections = List(
      name,
      synopsis,
      parameters,
      description,
      examples,
      authors,
      bugs,
      copyright,
      seeAlso)
  }
}