Author: Pedro Lucas Porcellis <porcellis@eletrotupi.com>
beterraba/parse: split args and cmd and return an actual service
beterraba/parse.ha | 16 ++++++++++++----
diff --git a/beterraba/parse.ha b/beterraba/parse.ha index dfd3271dfdbc6b65673518e6e574a1379c86e4ee..bd2fffbb87c12cad0036d84a5ea50049e39b0df8 100644 --- a/beterraba/parse.ha +++ b/beterraba/parse.ha @@ -6,10 +6,9 @@ use strings; export type invalid = !void; -export fn parse(in: io::handle) servdef = { +export fn parse(in: io::handle) service = { const scanner = ini::scan(in); - // TODO: Rig up with the type definition let definition = servdef { ... }; defer ini::finish(&scanner); @@ -36,7 +35,10 @@ switch (ent.1) { case "Type" => continue;// ¯\_(ツ)_/¯ case "ExecStart" => - definition.cmd = strings::dup(ent.2); + let cmdwithargs = strings::cut(ent.2, " "); + + definition.cmd = strings::dup(cmdwithargs.0); + definition.args = strings::dup(cmdwithargs.1); case "ExecReload" => definition.reloadcmd = strings::dup(ent.2); case "WorkingDirectory" => @@ -49,7 +51,13 @@ continue; }; }; - return definition; + return service { + name = strings::dup(definition.name), + desc = strings::dup(definition.desc), + definition = definition, + status = status::STOPPED, + ... + }; }; // Frees resources associated with this service definition