comp.lang.ada
 help / color / mirror / Atom feed
From: Jacob Sparre Andersen <sparre@nbi.dk>
Subject: ANN: Command Line Parser Generator
Date: Thu, 20 Aug 2015 15:15:33 +0200
Date: 2015-08-20T15:15:33+02:00	[thread overview]
Message-ID: <87io8aje2y.fsf@adaheads.sparre-andersen.dk> (raw)

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

             reply	other threads:[~2015-08-20 13:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-20 13:15 Jacob Sparre Andersen [this message]
2015-08-20 14:20 ` ANN: Command Line Parser Generator G.B.
2015-08-21  7:31   ` Jacob Sparre Andersen
2015-08-21  9:35     ` G.B.
2015-08-22  5:25       ` Jacob Sparre Andersen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox