commandline icon indicating copy to clipboard operation
commandline copied to clipboard

Making ParseArguments work easier with dependency injection

Open dmoonfire opened this issue 10 years ago • 0 comments

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);

dmoonfire avatar Mar 02 '15 23:03 dmoonfire