diff --git a/Program.cs b/Program.cs index 47d28a2..bfa192b 100644 --- a/Program.cs +++ b/Program.cs @@ -3,6 +3,7 @@ using System.IO; 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 +32,22 @@ private static void Main(string[] args) } ); - _ = parser.ParseArguments(args) + var parserResult = parser.ParseArguments(args); + parserResult .WithParsed(o => { Settings = o; new Program().Run(); - }); + }) + .WithNotParsed(x => + { + var helpText = HelpText.AutoBuild(parserResult, h => + { + h.AutoVersion = false; // hides --version + return HelpText.DefaultParsingErrorsHandler(parserResult, h); + }, e => e); + Console.Error.WriteLine(helpText); + }); } private void Run() diff --git a/Utils/CliOptions.cs b/Utils/CliOptions.cs index 9788025..2d95385 100644 --- a/Utils/CliOptions.cs +++ b/Utils/CliOptions.cs @@ -24,7 +24,7 @@ public class CliOptions [Option('f', "format", Required = true, HelpText = "Type of input file.")] public ReaderType Format { get; set; } - [Option('m', "modules", Required = false, HelpText = "Space-separated list of modules to run, or 'all'.")] + [Option('m', "modules", Required = false, Default = new string[] { "all" }, HelpText = "Space-separated list of modules to run, or 'all'.")] public IEnumerable ModuleNames { get; set; } = Array.Empty(); [Option('l', "read-limit", Required = false, HelpText = "Limit the number of reads processed")]