-
Notifications
You must be signed in to change notification settings - Fork 85
Open
Labels
Description
In version 1.4.3, FluentCommandLineParser<TBuildType>
requires that TBuildType
provides public parameterless constructor, using new()
generic parameter constraint. Will be nice to have a way to use arguments object without public parameterless constructor. For instance, by introducing FluentCommandLineParser<TBuildType>
constructor overload, which accepts Action<TBuildType>
factory method. It can be used to better argument object incapsulation, by prohibiting its creation outside of argument object factory method. For example:
internal class StartupArguments
{
public bool Argument1 { get; private set; }
public bool Argument2 { get; private set; }
public bool HelpCalled { get; set; }
// I can't do it private now :(
private StartupArguments()
{
}
public static StartupArguments Parse(string[] args)
{
// Just creates arguments object
var parser = new FluentCommandLineParser<StartupArguments>(() => new StartupArguments());
// Setup here
var parsingResult = parser.Parse(args);
parser.Object.HelpCalled = parsingResult.HelpCalled;
return parser.Object;
}
}
Lovely lib, mate 👍
clmcgrath