How would you create a console application from an existing object oriented API?-Collection of common programming errors
To get started on the command line, first don’t reinvent the wheel. There are a lot of options out there to parse commands.
In Java there is Commons CLI which provides you everything you need. There is a .NET CLI port as well.
InfiniteRed has a good writeup of how to do this in Ruby.
As far as implementation goes, you have the right idea. But don’t reinvent the wheel here, either. Encapsulate work in Command
objects and look at using the Chain of Responsibility pattern; Commons Chain works well. There is also a .NET Chain port.
If using these frameworks isn’t an option, take a look at how they’re implemented. Also if you’ve got a problem doing interop with some of these options, Ruby is really a nice swiss-army knife for doing this type of thing. It’s relatively portable and the code can end up being really clean and easy to maintain.
UPDATE: JCommander also looks interesting.