From 0020e641f653b80cbd3941cdd2433e3978c95c9e Mon Sep 17 00:00:00 2001 From: Nickc01 Date: Sat, 20 Nov 2021 00:39:05 -0600 Subject: [PATCH] Fixed an issue where the username was hardcoded --- .gitignore | 4 +++- README.md | 2 +- Wiki Page Generator/Program.cs | 34 ++++++++++++++++++++++++---------- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 9491a2f..5c50071 100644 --- a/.gitignore +++ b/.gitignore @@ -360,4 +360,6 @@ MigrationBackup/ .ionide/ # Fody - auto-generated XML schema -FodyWeavers.xsd \ No newline at end of file +FodyWeavers.xsd +.vscode/launch.json +.vscode/tasks.json diff --git a/README.md b/README.md index d3d6881..ea36231 100644 --- a/README.md +++ b/README.md @@ -8,5 +8,5 @@ For Other Platforms: [Download Here](https://dotnet.microsoft.com/download/dotne ``` Usage: -"Wiki Page Generator.exe" [REPO-NAME] [DESTINATION DIRECTORY] [CS Script File 1] [CS Script File 2] [CS Script File 2] [etc...] +"Wiki Page Generator.exe" [USERNAME OF REPO OWNER] [REPO-NAME] [DESTINATION DIRECTORY] [CS Script File 1] [CS Script File 2] [CS Script File 2] [etc...] ``` diff --git a/Wiki Page Generator/Program.cs b/Wiki Page Generator/Program.cs index 223c7d7..5673a60 100644 --- a/Wiki Page Generator/Program.cs +++ b/Wiki Page Generator/Program.cs @@ -53,38 +53,51 @@ class Program /// static string repoLink; + static void PrintCommandError(string msg) + { + Console.WriteLine(msg); + Console.WriteLine(); + Console.WriteLine("USAGE: [USERNAME OF REPO OWNER] [REPO-NAME] [DESTINATION DIRECTORY] [CS Script File 1] [CS Script File 2] [CS Script File 2] [etc...]"); + } + /// /// Main part of the program. /// USAGE: - /// "Wiki Page Generator.exe" [REPO NAME] [DESTINATION DIRECTORY] [CS Script File 1] [CS Script File 2] [CS Script File 2] [etc...] + /// "Wiki Page Generator.exe" [USERNAME OF REPO OWNER] [REPO NAME] [DESTINATION DIRECTORY] [CS Script File 1] [CS Script File 2] [CS Script File 2] [etc...] /// static void Main(string[] args) { if (args.GetLength(0) == 0) { - Console.WriteLine("ERROR : NO ARGUMENTS PASSED"); + PrintCommandError("ERROR : NO ARGUMENTS PASSED"); return; } if (args.GetLength(0) == 1) { - Console.WriteLine("ERROR : NO DESTINATION DIRECTORY SPECIFIED"); + PrintCommandError("ERROR : NO REPO NAME ENTERED"); return; } if (args.GetLength(0) == 2) { - Console.WriteLine("ERROR : NO CS FILES SPECIFIED"); + PrintCommandError("ERROR : NO DESTINATION DIRECTORY SPECIFIED"); + return; + } + + if (args.GetLength(0) == 3) + { + PrintCommandError("ERROR : NO CS FILES SPECIFIED"); return; } var watch = Stopwatch.StartNew(); totalPages.Clear(); - repoLink = $"https://github.com/nickc01/{args[0]}/wiki/"; + repoLink = $"https://github.com/{args[0]}/{args[1]}/wiki/"; - var dumpLocation = new DirectoryInfo(args[1]); + var dumpLocation = new DirectoryInfo(args[2]); - Parallel.For(2, args.Length, i => + Parallel.For(3, args.Length, i => { var extraction = ExtractAllInfo(args[i]); @@ -158,7 +171,8 @@ static void CreatePagesForMethods(DirectoryInfo outputDir, AllExtractedInfo info builder.Replace("*RIGHT*",param.Value); } } - File.WriteAllText(outputDir.FullName + "\\" + info.Class.ClassName + "-" + largestMethod.MethodName + "-(Method).md", builder.ToString()); + + File.WriteAllText(outputDir.FullName + Path.DirectorySeparatorChar + info.Class.ClassName + "-" + largestMethod.MethodName + "-(Method).md", builder.ToString()); addedPagesList.Add($"Page : {repoLink}{info.Class.ClassName}-{largestMethod.MethodName}-(Method)"); } @@ -195,7 +209,7 @@ static void CreateEnumWikiPage(DirectoryInfo outputDir, AllExtractedInfo info, L } } - File.WriteAllText(outputDir.FullName + "\\" + info.Enum.EnumName + "-(Script).md", builder.ToString()); + File.WriteAllText(outputDir.FullName + Path.DirectorySeparatorChar + info.Enum.EnumName + "-(Script).md", builder.ToString()); addedPagesList.Add($"Page : {repoLink}{info.Enum.EnumName}-(Script)"); } @@ -321,7 +335,7 @@ static void CreateClassWikiPage(DirectoryInfo outputDir, AllExtractedInfo info, } } - File.WriteAllText(outputDir.FullName + "\\" + info.Class.ClassName + "-(Script).md", builder.ToString()); + File.WriteAllText(outputDir.FullName + Path.DirectorySeparatorChar + info.Class.ClassName + "-(Script).md", builder.ToString()); addedPagesList.Add($"Page : {repoLink}{info.Class.ClassName}-(Script)"); }