diff --git a/Modules/ModuleFactory.cs b/Modules/ModuleFactory.cs index d3eb538..dea2b79 100644 --- a/Modules/ModuleFactory.cs +++ b/Modules/ModuleFactory.cs @@ -10,7 +10,7 @@ public static class ModuleFactory { private static Dictionary? moduleMap; - private static Dictionary ModuleMap + public static Dictionary ModuleMap { get { diff --git a/Program.cs b/Program.cs index 51626be..de896a9 100644 --- a/Program.cs +++ b/Program.cs @@ -1,8 +1,10 @@ using System; using System.Collections.Generic; using System.IO; +using System.Text; using System.Text.Json; using CommandLine; +using CommandLine.Text; using Ovation.FasterQC.Net.Modules; using Ovation.FasterQC.Net.Readers; using Ovation.FasterQC.Net.Utils; @@ -31,12 +33,36 @@ private static void Main(string[] args) } ); - _ = parser.ParseArguments(args) - .WithParsed(o => - { - Settings = o; - new Program().Run(); - }); + var parserResult = parser.ParseArguments(args); + + parserResult.WithParsed(o => + { + Settings = o; + new Program().Run(); + }) + .WithNotParsed(errs => DisplayHelp(parserResult, errs)); + } + + static void DisplayHelp(ParserResult result, IEnumerable errs) + { + var moduleList = ModuleFactory.ModuleMap; + var sb = new StringBuilder("List of available modules:").AppendLine(); + + foreach (var module in moduleList) + { + sb.AppendLine($"\t{module.Key} -> {module.Value.Description}"); + } + + var helpText = HelpText.AutoBuild(result, h => + { + h.AdditionalNewLineAfterOption = false; + h.MaximumDisplayWidth = 120; + h.AddPostOptionsText(sb.ToString()); + + return HelpText.DefaultParsingErrorsHandler(result, h); + }, e => e); + + Console.Error.WriteLine(helpText); } private void Run()