From a8ab419fcee610891602eac72ffe051db656e943 Mon Sep 17 00:00:00 2001 From: "Taylor C. Richberger" Date: Mon, 9 May 2016 17:08:23 -0600 Subject: resolve this, and improve help generation --- README.md | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 1f97f93..b3b3376 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # args A simple, small, flexible, single-header C++11 argument parsing library, in -about 1.3K lines of code. +about 1K lines of code. This is designed to somewhat replicate the behavior of Python's argparse, but in C++, with static type checking, and hopefully a lot faster. @@ -42,16 +42,14 @@ It: * Lets you parse, by default, any type that has a stream extractor operator for it. If this doesn't work for your uses, you can supply a function and parse the string yourself if you like. +* Lets you decide not to allow separate-argument argument flags or joined ones + (like disallowing `--foo bar`, requiring `--foo=bar`, or the inverse, or the + same for short options). # What does it not do? There are tons of things this library does not do! -## It does not yet: - -* Let you decide not to allow separate-argument argument flags or joined ones - (like disallowing `--foo bar`, requiring `--foo=bar`, or the inverse, or the - same for short options). ## It will not ever: @@ -65,6 +63,12 @@ There are tons of things this library does not do! `--foo` in the same parser), though shortopt and longopt prefixes can be different. * Allow you to have argument flags only optionally accept arguments +* Allow you to make flag arguments sensitive to order (like gnu find), or make + them sensitive to relative ordering with positional flags. The only + orderings that are order-sensitive are: + * Positional options relative to one-another + * List positional options or flag arguments to each of their own respective + items * Allow you to use a positional argument list before any other positional arguments (the last argument list will slurp all subsequent positional arguments). The logic for allowing this would be a lot more code than I'd @@ -112,16 +116,19 @@ can be pulled from their value and values attributes, if applicable. # How fast is it? This should not really be a question you ask when you are looking for an -argument-parsing library, but I did run a simple benchmark against args, TCLAP, -and boost::program_options, which parses the command line `-i 7 -c a 2.7 --char -b 8.4 -c c 8.8 --char d` with a parser that parses -i as an int, -c as a list -of chars, and the positional parameters as a list of doubles (the command line -was originally much more complex, but TCLAP's limitations made me trim it down -so I could use a common command line across all libraries. I also have to copy -in the arguments list with every run, because TCLAP permutes its argument list -as it runs (and comparison would have been unfair without comparing all about -equally), but that surprisingly didn't affect much. Also tested is pulling the -arguments out, but that was fast compared to parsing, as would be expected. +argument-parsing library, but every test I've done shows args as being about +65% faster than TCLAP and 220% faster than boost::program_options. + +The simplest benchmark I threw together is the following one, which parses the +command line `-i 7 -c a 2.7 --char b 8.4 -c c 8.8 --char d` with a parser that +parses -i as an int, -c as a list of chars, and the positional parameters as a +list of doubles (the command line was originally much more complex, but TCLAP's +limitations made me trim it down so I could use a common command line across +all libraries. I also have to copy in the arguments list with every run, +because TCLAP permutes its argument list as it runs (and comparison would have +been unfair without comparing all about equally), but that surprisingly didn't +affect much. Also tested is pulling the arguments out, but that was fast +compared to parsing, as would be expected. ### The run: -- cgit v1.2.1