I'm using the Command Line Parser Library I obtained via NuGet in my C# Console Application, .NET Framework 4.0.
Here's my options class...
class Options
{
[Option('p', "prompt", DefaultValue = true, HelpText = "Prompt the user before exiting the program.")]
public bool PromptForExit { get; set; }
[HelpOption]
public string GetUsage()
{
return HelpText.AutoBuild(this, (HelpText current) => HelpText.DefaultParsingErrorsHandler(this, current));
}
}
Here's where I parse and use the options...
static void Main(string[] args)
{
Options options = new Options();
if (CommandLine.Parser.Default.ParseArguments(args, options))
{
if (options.PromptForExit)
{
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}
}
}
I've tried all sorts of commands in an effort to get it to not prompt me before exiting, but none of them work. Is anyone familiar with this library or have an idea as to how I can get the PromptForExit option to be false from the command line?
Here's what I've tried.
myprogram.exe
myprogram.exe -p false
myprogram.exe -p False
myprogram.exe -p FALSE
myprogram.exe -p 0
myprogram.exe --prompt false
myprogram.exe --prompt False
myprogram.exe --prompt FALSE
myprogram.exe --prompt 0