diff --git a/Split-FANUC-Program-Backup/Program.cs b/Split-FANUC-Program-Backup/Program.cs
index 60c5d05..ab94c06 100644
--- a/Split-FANUC-Program-Backup/Program.cs
+++ b/Split-FANUC-Program-Backup/Program.cs
@@ -8,7 +8,7 @@
namespace SplitFANUCProgramBackup
{
- static class Program
+ public static class Program
{
private static string ThisExecutableName => AppDomain.CurrentDomain.FriendlyName;
private static Version? AssemblyVersion => Assembly.GetExecutingAssembly().GetName().Version;
@@ -26,7 +26,7 @@ private static string BuildDate
{
buildDateTime = new DateTime(2000, 1, 1).AddDays(version.Build).AddSeconds(version.Revision * 2);
}
-
+
return buildDateTime.ToString("o");
}
}
@@ -34,6 +34,7 @@ private static string BuildDate
private const string cncProgramFileExtension = ".CNC";
private const string defaultCNCprogramName = "Unknown";
private const char programDelimiter = '%';
+ private static readonly char[] subFolderTrim = { ' ', '/' };
private const int minimumProgramSize = 7;
///
@@ -47,7 +48,12 @@ private static string BuildDate
///
private const string directoryFlag = @"(&F=)";
- static async Task Main(string[] args)
+ ///
+ /// Command line entry point
+ ///
+ /// Requires only one argument: full path to the backup file.
+ /// Zero for success
+ public static async Task Main(string[] args)
{
DisplayHeader();
@@ -131,7 +137,7 @@ private static string GetProgramNameFromHeader(string cncProgramText)
///
/// Full path to "ALL-PROG.TXT"
/// Each CNC program as a string, and any associated subdirectory
- static IEnumerable<(string SubFolder, string ProgramText)> GetCNCProgams(string fileName, string outputFolder)
+ private static IEnumerable<(string SubFolder, string ProgramText)> GetCNCProgams(string fileName, string outputFolder)
{
StringBuilder content = new();
string subFolder = "";
@@ -150,7 +156,7 @@ private static string GetProgramNameFromHeader(string cncProgramText)
}
// Strip out the directory flag and slashes to get just the folder name.
- subFolder = Regex.Replace(line, directoryFlag, string.Empty).Trim('/');
+ subFolder = Regex.Replace(line, directoryFlag, string.Empty).Trim(subFolderTrim);
Directory.CreateDirectory(Path.Combine(outputFolder, subFolder));
// Don't append notation to next program
@@ -175,7 +181,7 @@ private static string GetProgramNameFromHeader(string cncProgramText)
yield return (subFolder, CncProgramText(content));
}
- static string CncProgramText(StringBuilder content)
+ private static string CncProgramText(StringBuilder content)
{
// Prevent IndexOutOfBounds exceptions if final program is empty
if (content.Length > minimumProgramSize)
@@ -202,7 +208,7 @@ private static void NotFoundError(string fileName)
Console.WriteLine("File not found: " + fileName);
}
- static void DisplayHelp()
+ private static void DisplayHelp()
{
Console.WriteLine(@"
At least one argument required. Enter only the path of the file you would like to split.
diff --git a/Split-FANUC-Program-Backup/Split-FANUC-Program-Backup.csproj b/Split-FANUC-Program-Backup/Split-FANUC-Program-Backup.csproj
index 35c1445..2a1ad3a 100644
--- a/Split-FANUC-Program-Backup/Split-FANUC-Program-Backup.csproj
+++ b/Split-FANUC-Program-Backup/Split-FANUC-Program-Backup.csproj
@@ -1,8 +1,8 @@
-
+
Exe
- net5.0-windows
+ net6.0-windows
SplitFANUCProgramBackup
False