Compare commits

..

No commits in common. "46a86f9ef8eab0412c73c77305dcadcbe27236bd" and "c8dd77878437c111d1bf2cf386ae62d05a526436" have entirely different histories.

6 changed files with 13 additions and 41 deletions

1
.gitignore vendored
View file

@ -545,4 +545,3 @@ FodyWeavers.xsd
.idea/**
*.txt
*.toml

View file

@ -1,2 +0,0 @@
global using Tomlyn;
global using System.Diagnostics;

View file

@ -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<TimeSpan>();
var storeSchedule = new List<String>();
// 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);
}

View file

@ -7,8 +7,4 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Tomlyn" Version="0.19.0" />
</ItemGroup>
</Project>

View file

@ -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

View file

@ -1,2 +0,0 @@
path = "/home/tonytins/Documents/"
file = "newscycle.txt"