Skip to content

Commit 685a361

Browse files
committed
doc draft
1 parent 920d5f2 commit 685a361

File tree

22 files changed

+488
-727
lines changed

22 files changed

+488
-727
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package build
2+
import mill.*, scalalib.*
3+
4+
import mill.define._
5+
import mill.define.SelectMode
6+
import mill.api.Result.create
7+
import mill.api.Result
8+
9+
object `package` extends ScalaModule {
10+
def scalaVersion = "2.13.11"
11+
def mvnDeps = Seq(
12+
mvn"com.lihaoyi::scalatags:0.13.1",
13+
mvn"com.lihaoyi::mainargs:0.6.2"
14+
)
15+
16+
object test extends ScalaTests {
17+
def mvnDeps = Seq(mvn"com.lihaoyi::utest:0.8.5")
18+
def testFramework = "utest.runner.Framework"
19+
}
20+
21+
def customSegmentCommand(evaluator: Evaluator, tasks: String*) = Task.Command(exclusive = true) {
22+
val segmentsResult = evaluator
23+
.resolveSegments(tasks, SelectMode.Multi)
24+
.get
25+
26+
segmentsResult.foreach { segment =>
27+
println(s"Segment: ${segment.parts.mkString(", ")}")
28+
}
29+
()
30+
}
31+
32+
}
33+
34+
// This command resolves the segments of the given tasks and prints them.
35+
// The segments are the parts of the task names that are used to group tasks.
36+
37+
/** Usage
38+
39+
> ./mill customSegmentCommand compile test
40+
Segment: compile
41+
Segment: test
42+
43+
*/
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package foo
2+
import scalatags.Text.all._
3+
import mainargs.{main, ParserForMethods}
4+
5+
object Foo {
6+
def generateHtml(text: String) = {
7+
h1(text).toString
8+
}
9+
10+
@main
11+
def main(text: String) = {
12+
println(generateHtml(text))
13+
}
14+
15+
def main(args: Array[String]): Unit = ParserForMethods(this).runOrExit(args)
16+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package foo
2+
3+
import utest._
4+
5+
object FooTests extends TestSuite {
6+
def tests = Tests {
7+
test("simple") {
8+
val result = Foo.generateHtml("hello")
9+
assert(result == "<h1>hello</h1>")
10+
result
11+
}
12+
test("escaping") {
13+
val result = Foo.generateHtml("<hello>")
14+
assert(result == "<h1>&lt;hello&gt;</h1>")
15+
result
16+
}
17+
}
18+
}

example/extending/evaluator/1-todo-webapp-report/build.mill

Lines changed: 0 additions & 114 deletions
This file was deleted.

0 commit comments

Comments
 (0)