[Issue 2993] getops uses globals for formatting

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Jul 12 07:46:39 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=2993

hsteoh at quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh at quickfur.ath.cx

--- Comment #2 from hsteoh at quickfur.ath.cx ---
The "standard" solution is to create a struct that encapsulates possible
configurations of getopt, and pass that as an optional first parameter:

    module std.getopt;
    struct GetoptConfig {
        dchar optionChar = ...
        string endOfOptions = ...;
        ... // etc.
    }

    module myprogram;
    void main(string[] args) {
        GetoptConfig cfg;
        cfg.endOfOptions = ...;
        cfg.getopt(args, ...);
    }

But this will break existing code, though.

--


More information about the Digitalmars-d-bugs mailing list