getopt & single-letter options with parameters
sk at metrokings.com
Sat Aug 7 20:08:26 PDT 2010
On Aug 7, 2010, at 4:22 PM, Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org
> On 08/07/2010 05:55 PM, Adrian Matoga wrote:
>> Is it by design that single-letter option needs to be glued to its
>> argument, like "-ofilename", or is it a bug in implementation?
>> import std.stdio;
>> import std.getopt;
>> void main(string args)
>> string outputFile;
>> "o|output-filename", &outputFile);
>> writeln("'" ~ outputFile ~ "'");
>> >test.exe -o somename
>> test.exe somename
>> >test.exe -osomename
>> Adrian Matoga
> It's by design in order to avoid confusion with parameterless
> options. Your example works with either of these invocations:
> ./prog -ofilename
> ./prog -o=filename
> ./prog --o=filename
> but not others.
The prevailing convention is to allow whitespace in this case. Would
Sorry for the accidental null post earlier.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Digitalmars-d