From 14537bba034b0fddecea8b4f8c9e4a76887ca57f Mon Sep 17 00:00:00 2001 From: Tony Bark Date: Sat, 22 Mar 2025 20:55:15 -0400 Subject: [PATCH] Fixed Not Exporting to the Proper User Directory - Removed new line when choosing a topic - Renamed newscycle.json to example.json in config - Changed path to "/" in config - If "/" is present in config, return the absolute current directory --- .gitignore | 2 +- Export.cs | 2 +- Interactive.cs | 6 ++---- README.md | 20 ++++++++++---------- Tracer.cs | 21 +++++++++++++++++++++ config.toml.sample | 4 ++-- 6 files changed, 37 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 2f4c5de..d830f82 100644 --- a/.gitignore +++ b/.gitignore @@ -546,4 +546,4 @@ FodyWeavers.xsd .idea/** *.txt *.toml -schedule.json \ No newline at end of file +example.json \ No newline at end of file diff --git a/Export.cs b/Export.cs index ec55658..7d4e895 100644 --- a/Export.cs +++ b/Export.cs @@ -48,9 +48,9 @@ internal static class Export public static void ToJSON(List storeTimes, string cfgPath) { // File directory is used for file location set in config - var outputDir = Directory.GetCurrentDirectory(); var topics = new List(); var config = GetConfig(cfgPath); + var outputDir = Tracer.OutputDirectory(config.Path!); var outputFile = config.File; var filePath = Path.Combine(outputDir, outputFile!); var chosenTopic = ""; diff --git a/Interactive.cs b/Interactive.cs index db2d3e8..5978eba 100644 --- a/Interactive.cs +++ b/Interactive.cs @@ -37,13 +37,11 @@ internal static class Interactive numOfTopics++; var title = community.Trim(); topicDict.Add(numOfTopics, title); - userChoices.Add( - $"{Environment.NewLine}{numOfTopics} {title.TrimEnd(new char[] { ',' })}" - ); + userChoices.Add($"{Environment.NewLine}{numOfTopics} {title}"); } var topicSelect = string.Join(", ", userChoices.ToArray()); - Console.WriteLine($"{Environment.NewLine}Choose a Topic{Environment.NewLine}{topicSelect}"); + Console.WriteLine($"Choose a Topic{Environment.NewLine}{topicSelect}"); var input = Console.ReadLine(); // Attempt to parse a number. diff --git a/README.md b/README.md index f95aa56..ff69c71 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# StaggerPost +# Stagger Post This is a very simple console application that suggests a list of times to post news articles within a randomized 2-3 hour and 30-minute delay to avoid conflicts. This keeps thing flowing at an organic and slow pace. -It is not recommended for use with hot topics. Instead, you should focus on overlooked foreign affairs, local news or op-eds. Of course, this is just covering general news. +It is not recommended for use with breaking news, of course. Instead, you should focus on overlooked local news or op-eds. Of course, this is just covering general news. It is really good niche communities. ## Exporting @@ -16,15 +16,15 @@ An optional ``config.toml`` file allows for further customization of file name, ```json [ - { - "topic": "Games", - "date": "3/16/2025", + { + "community": "games@lemmy.world", + "date": "3/22/2025", "times": [ - "11:41 AM", - "2:05 PM", - "5:05 PM", - "8:18 PM", - "11:02 PM" + "1:34 PM", + "3:03 PM", + "5:27 PM", + "9:13 PM", + "11:37 PM" ] } ] diff --git a/Tracer.cs b/Tracer.cs index a64c3a6..8ab4550 100644 --- a/Tracer.cs +++ b/Tracer.cs @@ -63,4 +63,25 @@ internal static class Tracer #endif } } + + /// + /// Determines the appropriate output directory based on the given directory path. + /// In DEBUG mode, it always returns the current working directory. + /// In release mode, it returns the provided directory unless it contains a '/', in which case it defaults to the current directory. + /// + /// The directory path to evaluate. + /// The resolved output directory as a string. + internal static string OutputDirectory(string dir) + { + var curDir = Directory.GetCurrentDirectory(); + +#if DEBUG + return curDir; +#else + if (dir.Contains("/")) + return curDir; + + return dir; +#endif + } } diff --git a/config.toml.sample b/config.toml.sample index 109b81f..2fe4c1e 100644 --- a/config.toml.sample +++ b/config.toml.sample @@ -1,5 +1,5 @@ -path = "/home/tonytins/Documents/" -file = "newscycle.json" +path = "/" +file = "example.json" communities = [ "Games", "News",