comp.lang.ada
 help / color / mirror / Atom feed
* ANN: Command Line Parser Generator
@ 2015-08-20 13:15 Jacob Sparre Andersen
  2015-08-20 14:20 ` G.B.
  0 siblings, 1 reply; 5+ messages in thread
From: Jacob Sparre Andersen @ 2015-08-20 13:15 UTC (permalink / 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-08-22  5:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-20 13:15 ANN: Command Line Parser Generator Jacob Sparre Andersen
2015-08-20 14:20 ` 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

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