Skip to content

Commit d60224f

Browse files
committed
Add :silent command to toggle automatic printing of outputs
1 parent b084a23 commit d60224f

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

compiler/src/dotty/tools/repl/ParseResult.scala

+6
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ object Reset {
9393
val command: String = ":reset"
9494
}
9595

96+
/** Toggle automatic printing of results */
97+
case object Silent extends Command:
98+
val command: String = ":silent"
99+
96100
/** `:quit` exits the repl */
97101
case object Quit extends Command {
98102
val command: String = ":quit"
@@ -113,6 +117,7 @@ case object Help extends Command {
113117
|:imports show import history
114118
|:reset [options] reset the repl to its initial state, forgetting all session entries
115119
|:settings <options> update compiler options, if possible
120+
|:reset disable/enable automatic printing of results
116121
""".stripMargin
117122
}
118123

@@ -137,6 +142,7 @@ object ParseResult {
137142
TypeOf.command -> (arg => TypeOf(arg)),
138143
DocOf.command -> (arg => DocOf(arg)),
139144
Settings.command -> (arg => Settings(arg)),
145+
Silent.command -> (_ => Silent),
140146
)
141147

142148
def apply(source: SourceFile)(using state: State): ParseResult = {

compiler/src/dotty/tools/repl/ReplDriver.scala

+2
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,8 @@ class ReplDriver(settings: Array[String],
537537
rootCtx = setupRootCtx(tokenize(arg).toArray, rootCtx)
538538
state.copy(context = rootCtx)
539539

540+
case Silent => state.copy(quiet = !state.quiet)
541+
540542
case Quit =>
541543
// end of the world!
542544
state

0 commit comments

Comments
 (0)