From 0abf87f017c5d57916757afdab43c1456b705abf Mon Sep 17 00:00:00 2001 From: Creeper Lv Date: Wed, 10 Aug 2022 02:38:57 +0800 Subject: [PATCH] CLUNL.ConsoleAppHelper 0.0.7.0 Fixed a crash in PrintHelp() when assembly file is not available. --- CLUNL.ConsoleAppHelper/CLUNL.ConsoleAppHelper.csproj | 2 +- CLUNL.ConsoleAppHelper/ConsoleAppHelper.cs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CLUNL.ConsoleAppHelper/CLUNL.ConsoleAppHelper.csproj b/CLUNL.ConsoleAppHelper/CLUNL.ConsoleAppHelper.csproj index 1732005..0685c14 100644 --- a/CLUNL.ConsoleAppHelper/CLUNL.ConsoleAppHelper.csproj +++ b/CLUNL.ConsoleAppHelper/CLUNL.ConsoleAppHelper.csproj @@ -3,7 +3,7 @@ net5.0 True - 0.0.6.0 + 0.0.7.0 https://github.com/creeperlv/CLUNL https://github.com/creeperlv/CLUNL diff --git a/CLUNL.ConsoleAppHelper/ConsoleAppHelper.cs b/CLUNL.ConsoleAppHelper/ConsoleAppHelper.cs index dfe5477..66c59fb 100644 --- a/CLUNL.ConsoleAppHelper/ConsoleAppHelper.cs +++ b/CLUNL.ConsoleAppHelper/ConsoleAppHelper.cs @@ -303,6 +303,10 @@ public static void Init(string FeatureCollectionID, string ProductName = "CLUNL" /// public static string LanguageConfigurationFile = null; /// + /// Override the default executable name by setting it to non-null value to avoid some crashing related to reflection. + /// + public static string ExecutableName = null; + /// /// Print out a auto-generated help document. /// public static void PrintHelp() @@ -336,7 +340,9 @@ public static void PrintHelp() var option = Language.Find("General.Console.Option", "Option"); var MainParameter = Language.Find("General.Console.MainParameter", "Main Parameter"); OutLine(); + if(ExecutableName==null) OutLine($"\t{new FileInfo(Assembly.GetEntryAssembly().Location).Name} (exe) <{command}> [{option}] [...] [{MainParameter}]"); + else OutLine($"\t{ExecutableName} (exe) <{command}> [{option}] [...] [{MainParameter}]"); OutLine(); OutLine(Language.Find("General.Console.Commands", "Commands:")); OutLine();