using Tommy; namespace RestySqlite { public class Utils { public static dynamic? ReadConfig(string key, string? category = null) { if (!File.Exists("conf.toml")) { TomlTable toml = new TomlTable { ["title"] = "Configuration file for API", ["api"] = { ["port"] = 5417, ["handle"] = "api", }, ["sql"] = { ["database"] = "" } }; using(StreamWriter writer = File.CreateText("conf.toml")) { toml.WriteTo(writer); // Remember to flush the data if needed! writer.Flush(); } Console.WriteLine("Config created please check it."); return null; } using(StreamReader reader = File.OpenText("conf.toml")) { TomlTable table = TOML.Parse(reader); if (category != null) { return table[category][key]; } return table[key]; } } } }