On Friday, 7 August 2015 at 11:40:54 UTC, Laeeth Isharc wrote:
What's the best way to check if an (optional) argument has been passed? One way is to use a default value, but I wonder if there is a tidier approach

Thanks.

(For startDate and endDate below)

struct NanoClientOptions
{
        string nanoUrl="tcp://127.0.0.1:9999";
        string[] tickers;
        DateTime startDate=DateTime(1,1,1);
        DateTime endDate=DateTime(9999,1,1);
}

auto helpInformation = getopt(
    args,
"nanoUrl", "Address of kaleidic data nanoserver eg tcp://127.0.0.1:9999", &options.nanoUrl, std.getopt.config.required, "ticker|t", "Tickers to download data for", &options.tickers,
            "startDate|s", "Start Date",                                    
&options.startDate,
            "endDate|e",       "End Date",                                  
&options.endDate
            );

Laeeth

I guess answer is simple: std.getopt doesn't handle DateTimes, so I have to use a callback, in which case I can just track whether it's been passed myself.

Reply via email to