digitalmars.D.learn - std.getopt: checking if an option has been passed
- Laeeth Isharc (22/22) Aug 07 2015 What's the best way to check if an (optional) argument has been
- Laeeth Isharc (4/26) Aug 07 2015 I guess answer is simple: std.getopt doesn't handle DateTimes, so
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
Aug 07 2015
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 ); LaeethI 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.
Aug 07 2015