From a80eef158556ebff509a30bafdbc33a03330e580 Mon Sep 17 00:00:00 2001 From: Jon Pretty Date: Sun, 6 Oct 2024 20:04:50 +0200 Subject: [PATCH] Rename `ExitStatus` to `Exit` --- src/core/guillotine.Computable.scala | 6 +++--- src/core/guillotine.PosixCommands.scala | 28 ++++++++++++------------- src/core/guillotine.Process.scala | 6 +++--- src/test/tests.scala | 8 +++---- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/core/guillotine.Computable.scala b/src/core/guillotine.Computable.scala index 6786979..23f4a6c 100644 --- a/src/core/guillotine.Computable.scala +++ b/src/core/guillotine.Computable.scala @@ -47,9 +47,9 @@ object Computable: given (using streamCut: Tactic[StreamError]) => LazyList[Bytes] is Computable as dataStream = proc => Readable.inputStream.stream(proc.getInputStream.nn) - given ExitStatus is Computable as exitStatus = _.waitFor() match - case 0 => ExitStatus.Ok - case other => ExitStatus.Fail(other) + given Exit is Computable as exitStatus = _.waitFor() match + case 0 => Exit.Ok + case other => Exit.Fail(other) given Unit is Computable = exitStatus.map(_ => ()) diff --git a/src/core/guillotine.PosixCommands.scala b/src/core/guillotine.PosixCommands.scala index 7054cc4..7289b8a 100644 --- a/src/core/guillotine.PosixCommands.scala +++ b/src/core/guillotine.PosixCommands.scala @@ -31,14 +31,14 @@ trait PosixCommands: erased given ("batch" is Intelligible into Text) as batch = ### erased given ("bc" is Intelligible into Text) as bc = ### erased given ("cat" is Intelligible into LazyList[Text]) as cat = ### - erased given ("chgrp" is Intelligible into ExitStatus) as chgrp = ### - erased given ("chmod" is Intelligible into ExitStatus) as chmod = ### - erased given ("chown" is Intelligible into ExitStatus) as chown = ### + erased given ("chgrp" is Intelligible into Exit) as chgrp = ### + erased given ("chmod" is Intelligible into Exit) as chmod = ### + erased given ("chown" is Intelligible into Exit) as chown = ### erased given ("cksum" is Intelligible into Text) as cksum = ### erased given ("cmp" is Intelligible into Text) as cmp = ### erased given ("comm" is Intelligible into Text) as comm = ### erased given ("command" is Intelligible into Text) as command = ### - erased given ("cp" is Intelligible into ExitStatus) as cp = ### + erased given ("cp" is Intelligible into Exit) as cp = ### erased given ("crontab" is Intelligible into Text) as crontab = ### erased given ("csplit" is Intelligible into Text) as csplit = ### erased given ("cut" is Intelligible into Text) as cut = ### @@ -65,8 +65,8 @@ trait PosixCommands: erased given ("iconv" is Intelligible into Text) as iconv = ### erased given ("id" is Intelligible into Text) as id = ### erased given ("join" is Intelligible into Text) as join = ### - erased given ("kill" is Intelligible into ExitStatus) as kill = ### - erased given ("ln" is Intelligible into ExitStatus) as ln = ### + erased given ("kill" is Intelligible into Exit) as kill = ### + erased given ("ln" is Intelligible into Exit) as ln = ### erased given ("locale" is Intelligible into Text) as locale = ### erased given ("localedef" is Intelligible into Text) as localedef = ### erased given ("logger" is Intelligible into Text) as logger = ### @@ -77,10 +77,10 @@ trait PosixCommands: erased given ("mailx" is Intelligible into Text) as mailx = ### erased given ("man" is Intelligible into LazyList[Text]) as man = ### erased given ("mesg" is Intelligible into Text) as mesg = ### - erased given ("mkdir" is Intelligible into ExitStatus) as mkdir = ### - erased given ("mkfifo" is Intelligible into ExitStatus) as mkfifo = ### - erased given ("mv" is Intelligible into ExitStatus) as mv = ### - erased given ("newgrp" is Intelligible into ExitStatus) as newgrp = ### + erased given ("mkdir" is Intelligible into Exit) as mkdir = ### + erased given ("mkfifo" is Intelligible into Exit) as mkfifo = ### + erased given ("mv" is Intelligible into Exit) as mv = ### + erased given ("newgrp" is Intelligible into Exit) as newgrp = ### erased given ("od" is Intelligible into Text) as od = ### erased given ("paste" is Intelligible into Text) as paste = ### erased given ("patch" is Intelligible into Text) as patch = ### @@ -92,10 +92,10 @@ trait PosixCommands: erased given ("pwd" is Intelligible into Text) as pwd = ### erased given ("read" is Intelligible into Text) as read = ### erased given ("renice" is Intelligible into Text) as renice = ### - erased given ("rm" is Intelligible into ExitStatus) as rm = ### - erased given ("rmdir" is Intelligible into ExitStatus) as rmdir = ### + erased given ("rm" is Intelligible into Exit) as rm = ### + erased given ("rmdir" is Intelligible into Exit) as rmdir = ### erased given ("sed" is Intelligible into LazyList[Text]) as sed = ### - erased given ("sleep" is Intelligible into ExitStatus) as sleep = ### + erased given ("sleep" is Intelligible into Exit) as sleep = ### erased given ("sort" is Intelligible into LazyList[Text]) as sort = ### erased given ("split" is Intelligible into Text) as split = ### erased given ("strings" is Intelligible into LazyList[Text]) as strings = ### @@ -104,7 +104,7 @@ trait PosixCommands: erased given ("tail" is Intelligible into LazyList[Text]) as tail = ### erased given ("tee" is Intelligible into Text) as tee = ### erased given ("test" is Intelligible into Text) as test = ### - erased given ("touch" is Intelligible into ExitStatus) as touch = ### + erased given ("touch" is Intelligible into Exit) as touch = ### erased given ("tput" is Intelligible into Text) as tput = ### erased given ("tr" is Intelligible into Text) as tr = ### erased given ("tsort" is Intelligible into Text) as tsort = ### diff --git a/src/core/guillotine.Process.scala b/src/core/guillotine.Process.scala index 185ace1..1cb6043 100644 --- a/src/core/guillotine.Process.scala +++ b/src/core/guillotine.Process.scala @@ -60,9 +60,9 @@ class Process[+ExecType <: Label, ResultType](process: java.lang.Process) extend def await()(using computable: ResultType is Computable): ResultType = computable.compute(process) - def exitStatus(): ExitStatus = process.waitFor() match - case 0 => ExitStatus.Ok - case other => ExitStatus.Fail(other) + def exitStatus(): Exit = process.waitFor() match + case 0 => Exit.Ok + case other => Exit.Fail(other) def abort(): Unit logs ExecEvent = Log.info(ExecEvent.AbortProcess(pid)) diff --git a/src/test/tests.scala b/src/test/tests.scala index 08870c4..af7c6dd 100644 --- a/src/test/tests.scala +++ b/src/test/tests.scala @@ -229,12 +229,12 @@ object Tests extends Suite(t"Guillotine tests"): .assert(_ <= 100L) test(t"successful exit status"): - sh"echo hello".exec[ExitStatus]() - .assert(_ == ExitStatus.Ok) + sh"echo hello".exec[Exit]() + .assert(_ == Exit.Ok) test(t"failed exit status"): - sh"false".exec[ExitStatus]() - .assert(_ == ExitStatus.Fail(1)) + sh"false".exec[Exit]() + .assert(_ == Exit.Fail(1)) test(t"nested command"): val cmd = sh"echo 'Hello world'"