JasperFx / oakton

Parsing and Utilities for Command Line Tools in .Net
http://jasperfx.github.io/oakton
Apache License 2.0
308 stars 41 forks source link

Bug Fix: RunHelp fails when using a custom command creator #17

Closed lfoust closed 7 years ago

lfoust commented 7 years ago

When using a custom ICommandCreator to integrate an IOC container, the display of the help for a command fails due to the fact that Model/Option classes may not have parameterless constructors but Activator.CreateInstance is being used.

This change uses ICommandCreator whenver an object needs to be created so that IOC can participate. All calls to Activator.CreateInstance are limited to the ActivatorCommandCreator.

Due to the return type of IOaktonCommand in the existing ICommandCreator method, I added a second method which is used for non-command objects. I am not wild about this design but I didn't want to change ICommandCreator into a full blown IOC abstraction.

I am also looking for more feedback and guidance on the unit tests. I am not sure the best way to isolate the scenario of building the help for a command.

jeremydmiller commented 7 years ago

@lfoust Got it, and I'm sorry for being so slow on this one. This will be in 1.3.1 in a little bit