Skip to content

Commit

Permalink
Use Decodable instead of Decoder
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Feb 10, 2025
1 parent d6b2e4b commit 43e7199
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/core/ethereal-core.scala
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ def cli[BusType <: Matchable](using executive: Executive)
DaemonEvent.Exit(line().decode[Pid])

case t"i" =>
import Decoder.int
val cliInput: CliInput = if line() == t"p" then CliInput.Pipe else CliInput.Terminal
val pid: Pid = Pid(line().decode[Int])
val script: Text = line()
Expand Down Expand Up @@ -236,6 +237,8 @@ def cli[BusType <: Matchable](using executive: Executive)

lazy val color: ColorDepth =
import workingDirectories.systemProperty
import Decoder.int

if safely(Environment.colorterm[Text]) == t"truecolor" then ColorDepth.TrueColor
else ColorDepth
(safely(mute[ExecEvent](sh"tput colors".exec[Text]().decode[Int])).or(-1))
Expand Down Expand Up @@ -289,6 +292,7 @@ def cli[BusType <: Matchable](using executive: Executive)

supervise:
import logFormats.standard
import Decoder.int
given Message is Loggable = Log.route(Syslog(t"ethereal"))

val socket: jn.ServerSocket = jn.ServerSocket(0)
Expand Down
3 changes: 1 addition & 2 deletions src/core/ethereal.CliInput.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ package ethereal
import anticipation.*
import gossamer.*
import prepositional.*
import spectacular.*

object CliInput:
given decoder: Decoder[CliInput] = text => valueOf(text.lower.capitalize.s)
given decoder: CliInput is Decodable in Text = text => valueOf(text.lower.capitalize.s)
given encodable: CliInput is Encodable in Text = _.toString.tt.lower

enum CliInput:
Expand Down
1 change: 1 addition & 0 deletions src/core/ethereal.ClientConnection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package ethereal

import anticipation.*
import contingency.*
import guillotine.*
import parasite.*
import profanity.*
import rudiments.*
Expand Down
2 changes: 1 addition & 1 deletion src/core/ethereal.DaemonEvent.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package ethereal

import anticipation.*
import guillotine.*
import profanity.*
import rudiments.*

import language.experimental.pureFunctions

Expand Down
2 changes: 1 addition & 1 deletion src/core/ethereal.DaemonLogEvent.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ package ethereal

import anticipation.*
import fulminate.*
import guillotine.*
import profanity.*
import rudiments.*

enum DaemonLogEvent:
case WriteExecutable(location: Text)
Expand Down
8 changes: 4 additions & 4 deletions src/core/ethereal.DaemonService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ package ethereal
import anticipation.*
import exoskeleton.*
import galilei.*
import guillotine.*
import prepositional.*
import proscenium.*
import rudiments.*
import serpentine.*

import language.experimental.pureFunctions

case class DaemonService[BusType <: Matchable]
(pid: Pid,
(pid: Pid,
shutdown: () => Unit,
cliInput: CliInput,
script: Path on Linux,
script: Path on Linux,
deliver: BusType => Unit,
bus: Stream[BusType],
bus: Stream[BusType],
scriptName: Text)
extends ShellContext:

Expand Down
1 change: 1 addition & 0 deletions src/core/ethereal.Installer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ object Installer:
if safely(scriptPath.decode[Path on Linux]) == service.script && !force
then Result.AlreadyOnPath(command, service.script.text)
else
import Decoder.int
val payloadSize: Memory = Memory(Properties.ethereal.payloadSize[Int]())
val jarSize: Memory = Memory(Properties.ethereal.jarSize[Int]())
val scriptFile: Path on Linux = service.script
Expand Down

0 comments on commit 43e7199

Please sign in to comment.