X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fcore%2Fgetopt.h;h=407d3459984fce67c42ffd92f1c9ffe7faae4b23;hp=f4e318e55d3eec1e8b14a160101e75c7be9e9cbb;hb=9be92503cda27dffd8c3219ec4cfadaee37b6369;hpb=5305cabf0b20a99a82aff4bcef26f2be0a8fd757 diff --git a/source/core/getopt.h b/source/core/getopt.h index f4e318e..407d345 100644 --- a/source/core/getopt.h +++ b/source/core/getopt.h @@ -33,12 +33,12 @@ the string "-abc" could be interpreted as having the options 'a', 'b' and 'c'. If the option takes an argument and there are unused characters in the argv element, then those characters are interpreted as the argument. Otherwise the next element is taken as the argument. An optional argument must be given in -the same element. +the same element if it is given. Long options begin with a double dash and are identified by an arbitrary string. An argument can be specified either in the same argv element, separated by an equals sign, or in the next element. As with short options, -an optional argument must be in the same element. +an optional argument, if given, must be in the same element. A single option may have both alternative forms, but must always have at least a long form. This is to encourage self-documenting options; it's much easier @@ -220,9 +220,9 @@ public: /** Adds an option with both short and long forms. Processing depends on the type of the destination variable and whether an argument is taken or - not. With an argument, the value is lexical_cast to appropriate type and - stored in the destination. Without an argument, a bool will be set to true - and an unsigned will be incremented; any other type will be ignored. */ + not. With an argument, the value is lexical_cast to the appropriate type + and stored in the destination. Without an argument, a bool will be set to + true and an unsigned will be incremented; any other type will be ignored. */ template Option &add_option(char s, const std::string &l, T &d, ArgType a = NO_ARG) { return add_option(s, l, SimpleStore(d), a); } @@ -272,8 +272,10 @@ private: unsigned process_short(const char *const *); public: - /** Generates a single line that describes known options and arguments. */ - std::string generate_usage(const std::string &) const; + /** Generates a single line that describes known options and arguments. If + compact is true, the options list is replaced with a placeholder. This + provides cleaner output if full help text is printed. */ + std::string generate_usage(const std::string &, bool compact = false) const; /** Generates help for known options and arguments in tabular format, one item per line. The returned string will have a linefeed at the end. */