diff --git a/Wabbajack.Common/CLI.cs b/Wabbajack.Common/CLI.cs index ce1bb3cc..20c5081c 100644 --- a/Wabbajack.Common/CLI.cs +++ b/Wabbajack.Common/CLI.cs @@ -6,14 +6,17 @@ namespace Wabbajack.Common { public static class CLIArguments { - [CLIOptions("nosettings")] + [CLIOptions("nosettings", HelpText = "Don't load the saved Settings")] public static bool NoSettings { get; set; } - [CLIOptions("apikey")] + [CLIOptions("apikey", HelpText = "Manually input an Nexus api key")] public static string ApiKey { get; set; } - [CLIOptions("install", ShortOption = 'i')] + [CLIOptions("install", ShortOption = 'i', HelpText = "Install a ModList via CLI")] public static string InstallPath { get; set; } + + [CLIOptions("help", ShortOption = 'h', HelpText = "Display this message")] + public static bool Help { get; set; } } public static class CLI @@ -40,6 +43,26 @@ namespace Wabbajack.Common }); } + public static void DisplayHelpText() + { + Console.WriteLine("Wabbajack CLI Help Text"); + Console.WriteLine("{0,-20} | {1,-15} | {2,-30}", "Option", "Short Option", "Help Text"); + + typeof(CLIArguments).GetProperties().Do(p => + { + var optionAttr = (CLIOptions[])p.GetCustomAttributes(typeof(CLIOptions)); + if (optionAttr.Length != 1) + return; + + var cur = optionAttr[0]; + if (cur?.Option == null) return; + + var shortText = cur.ShortOption != 0 ? $"-{cur.ShortOption}" : ""; + var helpText = string.IsNullOrWhiteSpace(cur.HelpText) ? "" : cur.HelpText; + Console.WriteLine("{0,-20} | {1,-15} | {2,-30}", $"--{cur.Option}", shortText, helpText); + }); + } + private static void FillVariable(dynamic option, ref PropertyInfo p, ref string[] args, bool single) { var s = single ? $"-{option}" : $"--{option}"; @@ -70,6 +93,8 @@ namespace Wabbajack.Common public string Option; // -shortOption, short name of the option. Eg: -o public char ShortOption; + // text to be displayed when --help is called + public string HelpText; public CLIOptions(string option) { diff --git a/Wabbajack/App.xaml.cs b/Wabbajack/App.xaml.cs index 9672d5a6..ad59de68 100644 --- a/Wabbajack/App.xaml.cs +++ b/Wabbajack/App.xaml.cs @@ -15,6 +15,8 @@ namespace Wabbajack public App() { CLI.ParseOptions(Environment.GetCommandLineArgs()); + if(CLIArguments.Help) + CLI.DisplayHelpText(); } } }