[Issue 18019] New: getopt worng behaviour (ConvException instead of GetOptException)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Nov 29 08:58:36 UTC 2017
https://issues.dlang.org/show_bug.cgi?id=18019
Issue ID: 18019
Summary: getopt worng behaviour (ConvException instead of
GetOptException)
Product: D
Version: D2
Hardware: x86_64
OS: Windows
Status: NEW
Severity: minor
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: dmitry at indiedev.ru
Code:
import std.stdio, std.getopt;
void main(string[] args)
{
bool replace;
auto helpInformation = getopt(args,
"replace|r", "Overwrite original file", &replace);
if (helpInformation.helpWanted)
{
defaultGetoptPrinter("test", helpInformation.options);
return;
}
}
As I understand, now getopt should recognize "-r", "--replace", "-h" and
"--help" options.
And they works fine:
$ app.exe -h
test
-r --replace Overwrite original file
-h --help This help information.
$ app.exe -r
$ app.exe --help
test
-r --replace Overwrite original file
-h --help This help information.
$ app.exe --replace
But if enter "-help" or "-replace", there is a problem.
$ app.exe -help
std.getopt.GetOptException at C:\D\dmd2\windows\bin\..\..\src\phobos\std\getopt.d(789):
Unrecognized option -help
$ app.exe -replace
std.conv.ConvException at C:\D\dmd2\windows\bin\..\..\src\phobos\std\conv.d(2018):
Can't parse string: bool should be case-insensitive 'true' or 'false'
----------------
0x00404620
0x00404814
0x004044E5
0x00402873
0x004022D7
0x0040221A
0x004094CF
0x00409493
0x00409394
0x00406CAF
0x765B336A in BaseThreadInitThunk
0x77DB98F2 in RtlInitializeExceptionChain
0x77DB98C5 in RtlInitializeExceptionChain
1) Why "-help" and "-replace" was recognized as options? They contains more
than one letter and bundling is disabled (as default).
2) At least, the behaviour should be same - "-replace" should throw
GetOptException.
If I don't understand something obvious, correct me, please.
--
More information about the Digitalmars-d-bugs
mailing list