/
SpecificationLevel.scala
78 lines (67 loc) · 3.02 KB
/
SpecificationLevel.scala
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
package scala.cli.commands
import caseapp.annotation.Tag
import os.copy
sealed trait SpecificationLevel extends Product with Serializable {
def md = toString() + " have"
}
/** Specification levels in the context of Scala CLI runner specification. For more refer to
* [SIP-46](https://github.com/scala/improvement-proposals/pull/46)
*
* Levels are also used to mark if given option, directive or command is part of stable API.
*/
object SpecificationLevel {
/** Marks option, directive or command that MUST be a part of any Scala Runner Specification (in
* RFC meaning). Annotated thing will be included in a new `scala` command.
*
* This also means that that thing should be sable and we need to support it.
*/
case object MUST extends SpecificationLevel
/** Marks option, directive or command that SHOULD be a part of any Scala Runner Specification (in
* RFC meaning). Annotated thing will be included in a new `scala` command.
*
* This also means that that thing should be sable and we need to support it.
*/
case object SHOULD extends SpecificationLevel
/** Marks option, directive or command that is an implementation details of Scala CLI and will not
* be a part of any Scala Runner Specification. Annotated thing will be included in a new `scala`
* command.
*
* This also means that that thing should be sable and we need to support it.
*/
case object IMPLEMENTATION extends SpecificationLevel {
override def md = toString() + " specific"
}
/** Annotated option, directive or command will not be a part of the Scala Runner Specification
* and will not be avialiable in the new `scala` command.
*
* This also means that that thing should be sable and we need to support it.
*/
case object RESTRICTED extends SpecificationLevel {
override def md = "Scala CLI specific"
}
/** Annotated option, directive or command will not be a part of the Scala Runner Specification
* and will not be avialiable in the new `scala` command.
*
* Experimental option are not guarantee to be supported in upcoming versions of Scala CLI and
* all new options should be experimental.
*/
case object EXPERIMENTAL extends SpecificationLevel {
override def md: String = toString()
}
val inSpecification = Seq(MUST, SHOULD)
}
object tags {
val experimental = SpecificationLevel.EXPERIMENTAL.toString()
val restricted = SpecificationLevel.RESTRICTED.toString()
val implementation = SpecificationLevel.IMPLEMENTATION.toString()
val must = SpecificationLevel.MUST.toString()
val should = SpecificationLevel.SHOULD.toString()
def levelFor(name: String) = name match {
case `experimental` => Some(SpecificationLevel.EXPERIMENTAL)
case `restricted` => Some(SpecificationLevel.RESTRICTED)
case `implementation` => Some(SpecificationLevel.IMPLEMENTATION)
case `must` => Some(SpecificationLevel.MUST)
case `should` => Some(SpecificationLevel.SHOULD)
case _ => None
}
}