Readd incomplete changes, now without missing apply method

This commit is contained in:
Alexander Gehrke 2022-09-21 15:47:47 +02:00
parent 0d797ea684
commit 517720c720

View file

@ -126,22 +126,29 @@ case class Pause(millisec: Long) extends Slide
case object PauseKey extends Slide case object PauseKey extends Slide
case class Meta(contents: (Presentation, Int) => Slide) extends Slide case class Meta(contents: (Presentation, Int) => Slide) extends Slide
case class TypedCommand[T](exec: T => String, display: String, cmd: T) extends Slide: case class TypedCommand[T](exec: T => String, display: String, cmd: T, cmdIsHidden: Boolean, outputIsHidden: Boolean) extends Slide:
private lazy val _output = exec(cmd) private lazy val _output = exec(cmd)
def output = _output def output = _output
infix def showing (s: String): TypedCommand[T] = TypedCommand(exec, s, cmd) infix def showing (s: String): TypedCommand[T] = TypedCommand(exec, s, cmd)
def show() = def show() =
force()
if ! cmdIsHidden then
prompt() prompt()
Terminal.showCursor() Terminal.showCursor()
typeCmd() typeCmd()
if ! outputIsHidden then
print(output) print(output)
if ! cmdIsHidden then
Terminal.hideCursor() Terminal.hideCursor()
def quickShow() = def quickShow() =
force()
if ! cmdIsHidden then
prompt() prompt()
println(display) println(display)
if ! outputIsHidden then
print(output) print(output)
def prompt() = print(fansi.Color.LightGreen("user@host % ")) def prompt() = print(fansi.Color.LightGreen("user@host % "))
@ -180,6 +187,10 @@ object TypedCommand:
def apply(cmd: String*)(using Path): TypedCommand[Vector[String]] = def apply(cmd: String*)(using Path): TypedCommand[Vector[String]] =
TypedCommand(run, cmd.mkString(" "), cmd.toVector) TypedCommand(run, cmd.mkString(" "), cmd.toVector)
def apply[T](exec: T => String, display: String, cmd: T) =
new TypedCommand(exec, display, cmd, false, false)
def shell(cmd: String*)(using Path): TypedCommand[Vector[String]] = def shell(cmd: String*)(using Path): TypedCommand[Vector[String]] =
TypedCommand(runShell, cmd.mkString(" "), cmd.toVector) TypedCommand(runShell, cmd.mkString(" "), cmd.toVector)