{"id":5332,"date":"2014-03-30T20:48:56","date_gmt":"2014-03-30T20:48:56","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/how-would-you-create-a-console-application-from-an-existing-object-oriented-api-collection-of-common-programming-errors\/"},"modified":"2014-03-30T20:48:56","modified_gmt":"2014-03-30T20:48:56","slug":"how-would-you-create-a-console-application-from-an-existing-object-oriented-api-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/how-would-you-create-a-console-application-from-an-existing-object-oriented-api-collection-of-common-programming-errors\/","title":{"rendered":"How would you create a console application from an existing object oriented API?-Collection of common programming errors"},"content":{"rendered":"<p>To get started on the command line, first don&#8217;t reinvent the wheel. There are a lot of options out there to parse commands.<\/p>\n<p>In Java there is Commons CLI which provides you everything you need. There is a .NET CLI port as well.<\/p>\n<p>InfiniteRed has a good writeup of how to do this in Ruby.<\/p>\n<p>As far as implementation goes, you have the right idea. But don&#8217;t reinvent the wheel here, either. Encapsulate work in <code>Command<\/code> objects and look at using the Chain of Responsibility pattern; Commons Chain works well. There is also a .NET Chain port.<\/p>\n<p>If using these frameworks isn&#8217;t an option, take a look at how they&#8217;re implemented. Also if you&#8217;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&#8217;s relatively portable and the code can end up being really clean and easy to maintain.<\/p>\n<p>UPDATE: JCommander also looks interesting.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To get started on the command line, first don&#8217;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. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5332","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5332","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5332"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5332\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5332"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5332"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5332"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}