Skip to content

Commit 3785e4f

Browse files
authored
Output help message when no operation was performed (#65)
***NO_CI***
1 parent 509e1a5 commit 3785e4f

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

nanoFirmwareFlasher/Program.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,8 +889,25 @@ static async Task RunOptionsAndReturnExitCodeAsync(Options o)
889889
}
890890
}
891891

892-
#endregion
892+
#endregion
893893

894+
// done nothing...
895+
// because of short-comings in CommandLine parsing
896+
// need to customize the output to provide a consistent output
897+
var parser = new Parser(config => config.HelpWriter = null);
898+
var result = parser.ParseArguments<Options>(new[] { "", "" });
899+
900+
var helpText = new HelpText(
901+
new HeadingInfo(_headerInfo),
902+
_copyrightInfo)
903+
.AddPreOptionsLine("")
904+
.AddPreOptionsLine("No operation was performed with the options supplied.")
905+
.AddPreOptionsLine("")
906+
.AddPreOptionsLine(HelpText.RenderUsageText(result))
907+
.AddPreOptionsLine("")
908+
.AddOptions(result);
909+
910+
Console.WriteLine(helpText.ToString());
894911
}
895912

896913
private static void OutputError(ExitCodes errorCode, bool outputMessage, string extraMessage = null)

0 commit comments

Comments
 (0)