You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into an odd problem with the above arguments. If I set (the unused) "--dummy=3", my application works fine but when I change it to "--dummy=4", I can no longer parse my object. I managed to modify your example application to catch this:
using System;
using CommandLine;
namespace QuickStart
{
class Program
{
public class Options
{
[Option('v', "verbose", Required = false)]
public bool Verbose { get; set; }
[Option("enabled", Required = false)]
public bool Enabled { get; set; }
[Option("width", Required = false)]
public int Width { get; set; }
[Option("rows", Required = false)]
public int Rows { get; set; }
[Option("cols", Required = false)]
public int Cols { get; set; }
}
static void Main(string[] args)
{
new Parser(with => { with.IgnoreUnknownArguments = true; })
.ParseArguments<Options>(args)
.WithParsed<Options>(o =>
{
if (o.Verbose)
{
Console.WriteLine($"Verbose output enabled. Current Arguments: -v {o.Verbose}");
Console.WriteLine("Quick Start Example! App is in Verbose mode!");
}
else
{
Console.WriteLine($"Current Arguments: -v {o.Verbose}");
Console.WriteLine($" Enabled: {o.Enabled}");
Console.WriteLine("Quick Start Example!");
}
})
.WithNotParsed(errors =>
{
foreach (var e in errors)
{
Console.WriteLine($"Error: {e} ({((MissingValueOptionError)e).NameInfo.LongName})");
}
});
}
}
}
With argument string "--enabled --width=1250 --rows=7 --cols=4 --dummy=3", the application properly indicates that enabled=true but when I change it to "--enabled --width=1250 --rows=7 --cols=4 --dummy=4", it indicates that the "cols" parameter is missing.
The text was updated successfully, but these errors were encountered:
I ran into an odd problem with the above arguments. If I set (the unused) "--dummy=3", my application works fine but when I change it to "--dummy=4", I can no longer parse my object. I managed to modify your example application to catch this:
With argument string "--enabled --width=1250 --rows=7 --cols=4 --dummy=3", the application properly indicates that enabled=true but when I change it to "--enabled --width=1250 --rows=7 --cols=4 --dummy=4", it indicates that the "cols" parameter is missing.
The text was updated successfully, but these errors were encountered: