Skip to content

Commit

Permalink
Use Scala 3-5-style Showable typeclass instead of Show
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Jun 12, 2024
1 parent b0e48fd commit 49b42c9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 25 deletions.
8 changes: 5 additions & 3 deletions src/core/guillotine.scala → src/core/guillotine-core.scala
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ object Command:
val commandText: Text = formattedArguments(command.arguments)
if commandText.contains(t"\"") then t"sh\"\"\"$commandText\"\"\"" else t"sh\"$commandText\""

given Show[Command] = command => formattedArguments(command.arguments)
given Command is Showable = command => formattedArguments(command.arguments)

case class Command(arguments: Text*) extends Executable:
def fork[ResultType]()(using working: WorkingDirectory)
Expand All @@ -244,7 +244,7 @@ object Pipeline:
pipeline => msg"${pipeline.commands.map(_.show).join(t" | ")}"

given Debug[Pipeline] = _.commands.map(_.debug).join(t" | ")
given Show[Pipeline] = _.commands.map(_.show).join(t" | ")
given Pipeline is Showable = _.commands.map(_.show).join(t" | ")

case class Pipeline(commands: Command*) extends Executable:
def fork[ResultType]()(using working: WorkingDirectory)
Expand Down Expand Up @@ -381,7 +381,6 @@ trait Parameterizable:
def show(value: Self): Text

object Guillotine:

def sh(context: Expr[StringContext], parts: Expr[Seq[Any]])(using Quotes): Expr[Command] =
import quotes.reflect.*

Expand All @@ -393,3 +392,6 @@ object Guillotine:
'{${Sh.Prefix.expand(context, parts)}.asInstanceOf[commandType]}

given Realm = realm"guillotine"

extension (inline context: StringContext)
transparent inline def sh(inline parts: Any*): Any = ${Guillotine.sh('context, 'parts)}
File renamed without changes.
22 changes: 0 additions & 22 deletions src/core/shextension.scala

This file was deleted.

0 comments on commit 49b42c9

Please sign in to comment.