diff --git a/.gitignore b/.gitignore index 6136cef..233762f 100644 --- a/.gitignore +++ b/.gitignore @@ -545,4 +545,3 @@ FodyWeavers.xsd .idea/** *.txt -*.toml diff --git a/GlobalUsings.cs b/GlobalUsings.cs deleted file mode 100644 index 8324182..0000000 --- a/GlobalUsings.cs +++ /dev/null @@ -1,2 +0,0 @@ -global using Tomlyn; -global using System.Diagnostics; diff --git a/Program.cs b/Program.cs index b4b0f6c..ce1a0c9 100644 --- a/Program.cs +++ b/Program.cs @@ -6,12 +6,6 @@ var startTime = new TimeSpan(9, 0, 0); // Starting time at 9:00 AM var random = new Random(); var scheduledTimes = new List(); var storeSchedule = new List(); -// App directory is used for config file -var appDir = Directory.GetCurrentDirectory(); -// File directory is used for file location set in config -var fileDir = Directory.GetCurrentDirectory(); -var scheduleFile = "schedule.txt"; -var cfgFile = "config.toml"; for (int i = 0; i < numberOfArticles; i++) { @@ -59,29 +53,12 @@ Console.WriteLine("Export? Y/N"); if (Console.ReadKey().Key == ConsoleKey.Y) { - var cfgPath = Path.Combine(appDir, cfgFile); - var filePath = Path.Combine(fileDir, scheduleFile); + var appPath = Directory.GetCurrentDirectory(); + var scheduleFile = "schedule.txt"; + var filePath = Path.Combine(appPath, scheduleFile); var appendSchedule = false; - // If the config file exists, read from that but don't assume anything is filled - if (File.Exists(cfgPath)) - { - var toml = File.ReadAllText(cfgPath); - var model = Toml.ToModel(toml); - var usrDir = (string)model["path"]; - var usrFileName = (string)model["file"]; - - if (!string.IsNullOrEmpty(usrDir)) - fileDir = usrDir; - - if (!string.IsNullOrEmpty(usrFileName)) - scheduleFile = usrFileName; - - // Set new file Path - filePath = Path.Combine(fileDir, scheduleFile); - } - - // If the file already exists, assume a previous schedule was written + // If the file already exists, assume the schedule was written if (File.Exists(filePath)) { Console.WriteLine($"{Environment.NewLine}Add another schedule? Y/N"); @@ -90,7 +67,7 @@ if (Console.ReadKey().Key == ConsoleKey.Y) } // Write to file. - using (var outputFile = new StreamWriter(filePath, appendSchedule)) + using (var outputFile = new StreamWriter(Path.Combine(appPath, scheduleFile), appendSchedule)) { // Add separator between times if (appendSchedule) @@ -99,7 +76,11 @@ if (Console.ReadKey().Key == ConsoleKey.Y) foreach (var line in storeSchedule) outputFile.WriteLine(line); } -} -// Clear list from memory before exit -storeSchedule.Clear(); + // Clear list and start over + storeSchedule.Clear(); +} +else +{ + Environment.Exit(Environment.ExitCode); +} diff --git a/PublishTimes.csproj b/PublishTimes.csproj index 109581c..fd4bd08 100644 --- a/PublishTimes.csproj +++ b/PublishTimes.csproj @@ -7,8 +7,4 @@ enable - - - - diff --git a/README.md b/README.md index 98d5dd7..ed804da 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This is a very simple console application that generates a list of times to sche ## Background -A while back, I [found a tool](https://schedule.lemmings.world) to schedule articles on Lemmy. I've been posting within a few hour apart at random minutes and I wanted to something decide that for me. I had AI write the base algorithm everything else is my own touches. +A while back, I [found a tool](https://schedule.lemmings.world) to schedule articles on Lemmy. I've been posting within a few hour apart at random minutes and I wanted to something decide that for me. I had AI write the algorithm. ## License diff --git a/config.toml.sample b/config.toml.sample deleted file mode 100644 index c49564a..0000000 --- a/config.toml.sample +++ /dev/null @@ -1,2 +0,0 @@ -path = "/home/tonytins/Documents/" -file = "newscycle.txt"