commandline
commandline copied to clipboard
Making ParseArguments work easier with dependency injection
I think it is great to pass in the argument types for the verb options.
Type[] argumentTypes = di.GetProcessArgumentTypes();
ParserResult<object> result = Parser.Default.ParseArguments(
args,
argumentTypes);
However, I use dependency injection pretty heavily and it isn't the easiest thing to get the types out of that. It would be fantastic if I could somehow pass in instance values instead of argument types.
IArguments arguments = di.GetProcessArguments();
ParserResult<object> result = Parser.Default.ParseArguments(
args,
arguments);
If you want some type safety, you could add a generic argument to that.
IArguments arguments = di.GetProcessArguments();
ParserResult<object> result = Parser.Default.ParseArguments<IArguments>(
args,
arguments);