[Issue 16684] std.getopt, problem with the automatic handling of "h"
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Thu Jan  5 01:49:42 PST 2017
    
    
  
https://issues.dlang.org/show_bug.cgi?id=16684
--- Comment #2 from b2.temp at gmx.com ---
(In reply to b2.temp from comment #1)
> @Alexandru, I think that the best fix is to
> 
> 1/ add a static assert() that prevents to specify "-h" or "--help"  (for
> example there's already "optionValidator" that does a few static checks) 
> 
> 2/ also update the documentation, saying that this switch is handled
> automatically
> 
> The real problem I had before reporting was 1 hour lost trying to get why a
> function pointer was never called. With a static check this will never
> happen anymore to anyone.
Forgot to say that the only way to handle "h" should be the getopt results, e.g
void main(string[] args)
{
    import std.getopt;
    auto h = getopt(args, config.passThrough);
    if (h.helpWanted) {}
}
That's why it can be rejected at compile time.
--
    
    
More information about the Digitalmars-d-bugs
mailing list