Almost all the .exe's I use via command line have a help function that gets called by the "--help" command.
How do I implement this in C#? Is it as simple as checking whether or not the parameter in args[] is the string "--help"??
With *nix commands, it's common to obtain help either via -h or --help. Many windows commands will offer help with /?. So it's not bad practice to do something like:
public static void Main(string[] args)
{
if (args.Length == 1 && HelpRequired(args[0]))
{
DisplayHelp();
}
else
{
...
}
}
private static bool HelpRequired(string param)
{
return param == "-h" || param == "--help" || param == "/?";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With