Declarative Command-line Interfaces
Damian M Conway · 1998
This paper describes a new approach to generating command-line argument parsers in Perl [1]. The system presented takes a standard "usage" description and reverse-engineers a parser which satisfies that description. This ability to specify complex parsers declaratively also proves useful in other contexts, such as comma-separated-value processing, simple input parsing, and string interpolation. Introduction Non sunt multiplicanda entia praeter necessitatem. - William of Occam In apparent defiance of Occam's Razor, command-line argument parsing libraries multiply beyond all reasonable necessity. A 1994 survey [2] compares a dozen libraries for C/C++ alone, whilst the Comprehensive Perl Archive Network catalogues nine distinct Perl packages for the same purpose. Worse still, this paper describes Getopt::Declare - yet another command-line argument parser for Perl. Command-line processing packages multiply because, despite its apparent simplicity, unrestricted commandline processing is...