init method
launch the process here feeding typically the command line arguments
Implementation
FibuSettings init(List<String> arguments) {
data = {};
usage = parser.usage;
data["error"] = false;
try {
var argResults = parser.parse(arguments);
//print("applying args: lang:${argResults["lang"]} base:${argResults["base"]} out:${argResults["output"]} help:${argResults["help"]} strict:${argResults["strict"]} rest: ${argResults.rest}");
argResults.options.forEach((key) {
var val = argResults[key];
data["$key"] = (val == null) ? "null" : val;
});
rest = argResults.rest;
//postprocessing
data["type"] = "csv"; //csv is default
if (data.containsKey("base") && data["base"].isNotEmpty) {
//ok... we have a filled in base....
var splitted = data["base"].split(".");
if (splitted.length >= 2) {
data["type"] = splitted.removeLast();
data["base"] = splitted.join(".");
}
if (data["type"] == "kpl" || data["type"] == "jrl")
data["type"] = "wbstyle";
//print("match! splitted ${data["base"]} from ${data["type"]}");
if (data["output"] == null) data["output"] = data["base"] + ".lst";
}
} catch (e) {
//print("unknown arguments, please stick to:\n"+parser.usage);
data["error"] = true;
}
if (data.containsKey("lang")) {
if (["lang"].length == 2)
data["lang"] =
data["lang"].toLowerCase() + "_" + data["lang"].toUpperCase();
if (data["lang"].length == 2)
data["lang"] =
data["lang"].toLowerCase() + "_" + data["lang"].toUpperCase();
//print("default locale: ${data["lang"]}");
Intl.defaultLocale = data["lang"];
}
initializeDateFormatting(Intl.defaultLocale);
return this;
}