Skip to content

Latest commit

 

History

History
40 lines (30 loc) · 4.56 KB

summary.md

File metadata and controls

40 lines (30 loc) · 4.56 KB

6.5. Summary

When comparing the different approaches to command-line parsing, it is apparent that—as expected—the more recent parsers have a larger set of features. While the Bash-builtin getopts parser comprises only minimal functionality (not even long options), it is the only one that solely implements the POSIX standard. A slightly greater number of features comes with GNU getopt, like long options and the ability to abbreviate them.

Later parsers as shFlags and especially docopts implement far more sophisticated functionality, like default values, mandatory options, or even an auto-generated help message. Still, they lack, e.g., choice values or the ability to localize messages.

Most of the Argparser's features are inspired by the Python argparse module, with extensions like the ++ positional arguments delimiter or the ability to negate and invert flags. This renders the Argparser far more powerful than even docopts, while at the same time trying to be more user-friendly.

This is especially noticeable for error messages when building the command line, where the Argparser gives detailled error messages instead of a generic text that just states that something failed. Further, the docopt(s) specification is rather complex, requiring elaborate comprehension on how to write the help message. The Argparser, in contrast, aims at a clearer user interface even for the programmer, by requiring a tabular arguments definition with headers.

Further, the development of shFlags and docopts seemingly has stalled, with no release or even commit for years. This renders it unlikely that these libraries will implement additional functionality, increasing the potential use for the Argparser.

Regarding the runtimes, the compiled tools are faster by one to two orders of magnitude. Still, the interpreted Bash scripts behind the Argparser and shFlags achieve a median runtime of about 120 ms and 280 ms, respectively, making the runtime a less important criterion when deciding which command-line parsing library to use.

Most importantly, the code length needed to use the parser is drastically reduced for the Argparser, with all other libraries needing the five- to eightfold number of lines to achieve the same thing—with an even higher ratio for more complex use cases.

Finally, the Argparser is extensively documented, unlike the other tools relying on a brief readme or man page. This hopefully makes the transition to the Argparser—if deemed useful at all—easier.

🡄 6.4. Code length comparison           7. Roadmap 🡆