Author: Pedro Lucas Porcellis <porcellis@eletrotupi.com>
types: convert a status str into their respective enum
beterraba/types.ha | 11 +++++++++++
diff --git a/beterraba/types.ha b/beterraba/types.ha index 7f57c69ccea5a7a1054c6615c5d4ef58e291f75d..f9d66b2c4082e4bc3636744dca3dac5e77fcbcfc 100644 --- a/beterraba/types.ha +++ b/beterraba/types.ha @@ -31,6 +31,17 @@ definition: servdef, process: exec::process }; +export fn statusfromstr(s: str) status = { + switch (s) { + case "started" => + return status::STARTED; + case "stopped" => + return status::STOPPED; + case "crashed" => + return status::CRASHED; + }; +}; + // Maps a [[service]] status into a friendly message export fn strstatus(s: status) const str = { switch (s) {