beterraba

commit f4ebe4651dc7b74e65fe0a9f4cb29c086c12798c

Author: Pedro Lucas Porcellis <porcellis@eletrotupi.com>

beterraba/parse: return a servdef and read cmd, desc and other fields

 beterraba/parse.ha | 29 +++++++++++++++++++++++++----


diff --git a/beterraba/parse.ha b/beterraba/parse.ha
index 30cb405d698e6d5110a3e2f63f54fcd9ecd993fc..d5df10f16d48dfea8cd41192fea1e2aa13fb4f99 100644
--- a/beterraba/parse.ha
+++ b/beterraba/parse.ha
@@ -4,10 +4,17 @@ use fmt;
 use format::ini;
 use strings;
 
-export type servdef = struct { name: str };
+export type servdef = struct {
+	name: str,
+	desc: str,
+	cmd: str,
+	wd: str,
+	reloadcmd: str
+};
+
 export type invalid = !void;
 
-export fn parse(in: io::handle) void = {
+export fn parse(in: io::handle) servdef = {
 	const scanner = ini::scan(in);
 
 	// TODO: Rig up with the type definition
@@ -27,6 +34,21 @@ 		case "Unit" =>
 			switch (ent.1) {
 			case "Name" =>
 				definition.name = strings::dup(ent.2);
+			case "Description" =>
+				definition.desc = strings::dup(ent.2);
+			case =>
+				continue;
+			};
+		case "Service" =>
+			switch (ent.1) {
+			case "Type" =>
+				continue;// ¯\_(ツ)_/¯
+			case "ExecStart" =>
+				definition.cmd = strings::dup(ent.2);
+			case "ExecReload" =>
+				definition.reloadcmd = strings::dup(ent.2);
+			case "WorkingDirectory" =>
+				definition.wd = strings::dup(ent.2);
 			case =>
 				continue;
 			};
@@ -35,6 +57,5 @@ 			continue;
 		};
 	};
 
-	// TODO: Fetch a use case
-	fmt::printfln("Unit name: {}", definition.name)!;
+	return definition;
 };