From 8cf1e917f6cbeb848cf4b0c2961e93593a38ab65 Mon Sep 17 00:00:00 2001 From: Tony Bark Date: Wed, 12 Mar 2025 02:11:58 -0400 Subject: [PATCH] Grab topics from config, if it exists --- GlobalUsings.cs | 3 ++- Program.cs | 17 +++++++++-------- config.toml.sample | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/GlobalUsings.cs b/GlobalUsings.cs index 8324182..ed65c75 100644 --- a/GlobalUsings.cs +++ b/GlobalUsings.cs @@ -1,2 +1,3 @@ global using Tomlyn; -global using System.Diagnostics; +global using Tomlyn.Model; +global using System.Globalization; diff --git a/Program.cs b/Program.cs index 90b0a46..24a4569 100644 --- a/Program.cs +++ b/Program.cs @@ -75,20 +75,21 @@ if (Console.ReadKey().Key == ConsoleKey.Y) var model = Toml.ToModel(toml); var usrDir = (string)model["path"]; var usrFileName = (string)model["file"]; - // var usrList = (string[])model["communities"]; + var tomlList = string.Join(", ", (TomlArray)model["topics"]); + var usrList = tomlList.Split(','); if (!string.IsNullOrEmpty(usrDir)) fileDir = usrDir; if (!string.IsNullOrEmpty(usrFileName)) scheduleFile = usrFileName; - /* - if (usrList.Length > 0) - { - var chooseUsrTopic = rng.Next(0, usrList.Length); - topic = usrList[chooseUsrTopic]; - } - */ + + if (usrList.Length > 0) + { + var chooseUsrTopic = rng.Next(0, usrList.Length); + topic = usrList[chooseUsrTopic]; + } + // Set new file Path filePath = Path.Combine(fileDir, scheduleFile); diff --git a/config.toml.sample b/config.toml.sample index 05f2ee1..73b1872 100644 --- a/config.toml.sample +++ b/config.toml.sample @@ -1,3 +1,3 @@ path = "/home/tonytins/Documents/" file = "newscycle.txt" -communities = [ "Games", "Politics", "Research", "Technology" ] +topics = [ "Games", "Technology", "Cybersecurity" ]