digitalmars.D.learn - Is it a bug in std.getopt.config.stopOnFirstNonOption?
- Andrey Zherikov (18/18) Aug 16 2019 Here is the code I have which doesn't work:
- =?UTF-8?Q?Ali_=c3=87ehreli?= (6/10) Aug 16 2019 Yes, it's a bug.
Here is the code I have which doesn't work: ``` string[] foo; string[] bar; auto args = ["app", "--bar", "bar", "--foo", "foo"]; // (1) import std.getopt; getopt(args, std.getopt.config.stopOnFirstNonOption, // (2) "foo", &foo, "bar", &bar); ``` The error I see: std.getopt.GetOptException c:\D\dmd-2.086.1\windows\bin\..\..\src\phobo \std\getopt.d(792): Unrecognized option --foo But: - if I change line (1) to `auto args = ["app", "--foo", "foo", "--bar", "bar"];` then this code works. - if I remove line (2) then this code works. What am I doing wrong?
Aug 16 2019
On 08/16/2019 02:07 PM, Andrey Zherikov wrote:But: - if I change line (1) to `auto args = ["app", "--foo", "foo", "--bar", "bar"];` then this code works. - if I remove line (2) then this code works.Yes, it's a bug. Another workaround--which I haven't tested to see whether produces the behavior you expect--is to move std.getopt.config.stopOnFirstNonOption to a later position the argument list, like after &foo. Ali
Aug 16 2019