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

* Re: ANN: Command Line Parser Generator
  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
  0 siblings, 1 reply; 5+ messages in thread
From: G.B. @ 2015-08-20 14:20 UTC (permalink / raw)


On 20.08.15 15:15, Jacob Sparre Andersen wrote:
> I would like to announce that I have brought my command line parser
> generator[1] to (what I assume is) a usable state.

I'd rather like to believe that, but the Makefile is not usable
in a Unix environment if it is not contemporary GNU/Linux ;-)
Target `fix-whitespace' stops progress due to incompatible
GNU xargs options. (A little shell script to invoke Perl
(or just Perl) would be a way out for users of BSD, Apple,
ActiveState, and GNAT. But I haven't looked close enough.)


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

* Re: ANN: Command Line Parser Generator
  2015-08-20 14:20 ` G.B.
@ 2015-08-21  7:31   ` Jacob Sparre Andersen
  2015-08-21  9:35     ` G.B.
  0 siblings, 1 reply; 5+ messages in thread
From: Jacob Sparre Andersen @ 2015-08-21  7:31 UTC (permalink / raw)


Georg Bauhaus wrote:

> I'd rather like to believe that, but the Makefile is not usable in a
> Unix environment if it is not contemporary GNU/Linux ;-)

I must admit that I consider the GNU style of long command line
arguments much more maintainable than the traditional UNIX style of
single letter arguments.  But to make life easier for non-GNU users,
I've updated the Makefile (and test scripts) to use single letter
arguments.

Greetings,

Jacob
-- 
"Facts are stubborn, but statistics are more pliable." -- Mark Twain


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

* Re: ANN: Command Line Parser Generator
  2015-08-21  7:31   ` Jacob Sparre Andersen
@ 2015-08-21  9:35     ` G.B.
  2015-08-22  5:25       ` Jacob Sparre Andersen
  0 siblings, 1 reply; 5+ messages in thread
From: G.B. @ 2015-08-21  9:35 UTC (permalink / raw)


On 21.08.15 09:31, Jacob Sparre Andersen wrote:
> Georg Bauhaus wrote:
>
>> I'd rather like to believe that, but the Makefile is not usable in a
>> Unix environment if it is not contemporary GNU/Linux ;-)
>
> I must admit that I consider the GNU style of long command line
> arguments much more maintainable than the traditional UNIX style of
> single letter arguments.  But to make life easier for non-GNU users,
> I've updated the Makefile (and test scripts) to use single letter
> arguments.

It's the option, not its name. (Long names are fines, also less
prone to ambiguity, across systems.)
"This option is a GNU extension", so it works on GNU systems.

I'll try to make something equivalent, based on POSIX. (That kind
of work is part of every day work life, so it shouldn't be hard.)


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

* Re: ANN: Command Line Parser Generator
  2015-08-21  9:35     ` G.B.
@ 2015-08-22  5:25       ` Jacob Sparre Andersen
  0 siblings, 0 replies; 5+ messages in thread
From: Jacob Sparre Andersen @ 2015-08-22  5:25 UTC (permalink / raw)


"G.B." <bauhaus@futureapps.invalid> writes:

> I'll try to make something equivalent, based on POSIX. (That kind of
> work is part of every day work life, so it shouldn't be hard.)

Thanks.  It will be very welcome.  (I could of course make a quick fix,
disabling it on non-GNU systems, as that target really only is relevant
during development.)

Greetings,

Jacob
-- 
»It will not be forever. - It will just seem like it.« -- Death

^ 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