From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!gandalf.srv.welterde.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: Jacob Sparre Andersen Newsgroups: comp.lang.ada Subject: ANN: Command Line Parser Generator Date: Thu, 20 Aug 2015 15:15:33 +0200 Organization: JSA Research & Innovation Message-ID: <87io8aje2y.fsf@adaheads.sparre-andersen.dk> NNTP-Posting-Host: 109.56.17.211.mobile.3.dk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: loke.gir.dk 1440076536 24186 109.56.17.211 (20 Aug 2015 13:15:36 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 20 Aug 2015 13:15:36 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Cancel-Lock: sha1:Lt0y9jSAXdq4Jbk2tGVEgCyAGAM= Xref: news.eternal-september.org comp.lang.ada:27524 Date: 2015-08-20T15:15:33+02:00 List-Id: I would like to announce that I have brought my command line parser generator[1] to (what I assume is) a usable state. Instead of manually implementing command line parsing using some library, you can collect all the ways your program can be called as procedures in a package. A simple example: package Filter is procedure Show_Help (Help : Boolean); -- Shows the usage instructions (no matter the value of 'Help'). procedure Process (Source_File : String := ""; Target_File : String := ""); -- Empty file names are mapped to respectively 'Standard_Input' -- and 'Standard_Output'. end Filter; Running (yes, I need a shorter name for it): command_line_parser_generator-run Filter in the directory containing 'filter.ads' generates 'generated/filter-driver.adb', which when compiled transforms command line arguments into procedure calls like this: --help -> Filter.Show_Help (Help => True); --source_file=data -> Filter.Process (Source_File => "data"); --target_file=out -> Filter.Process (Target_File => "out"); --source_file=data --target_file=out -> Filter.Process (Source_File => "data", Target_File => "out"); There are currently two known issues with the tool [2]: a) The tool assumes that all non-String types have a 'Value attribute, without checking if this is the case. b) The tool doesn't check if the type of a formal parameter has a primitive Value function (which should override the 'Value attribute). Enjoy! Jacob [1] http://repositories.jacob-sparre.dk/command-line-parser-generator/wiki/Home [2] http://repositories.jacob-sparre.dk/command-line-parser-generator/issues?status=new&status=open -- "In Ada you model the problem space, not the solution space." -- Robert I. Eachus