obsolete D libraries/modules

Jacob Carlborg doob at me.com
Tue Sep 3 12:01:58 PDT 2013


On 2013-09-02 16:16, Andrej Mitrovic wrote:

> W.r.t. help strings, I would prefer if we could instead use:
>
> getopt(args,
>    "timeout|t", &timeout, "Set the timeout",
>    "other", &other,  // note: no comment!
>    "flag|f", &flag, "Set the flag")
>
> I think we could make getopt support this. For example:
>
> ["foo", &foo] => name, field
> ["foo", &foo, "foo text"] => name, field, #3 is a comment
> ["foo", &foo, "foo text", "bar", &bar] => #3 is a commen
> ["foo", &foo, "foo text", &bar] => #3 is a new name
>
> Essentially all getopt has to do is slice up the arguments into
> groups, where an address and the string before it begin a new group.
>
> @Andrei: What do you think?

Could we get some form of API to set a header and footer that is printed 
with the help text. Possible idea:

bool help;

getopt(args, "h|help", &help, @doc("Show this message and exit.");
getopt.header = "Usage foo [options]\nVersion 0.0.1\n\n";
getopt.footer = "\n\nUse the 'h' flag for help.";

Will print:

Usage foo [options]
Version 0.0.1

Options:
     -h, --help    Show this message and exit.

Use the 'h' flag for help.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list