Allowing string value with getopt without requiring it
Ithy
n at n.n
Thu Dec 12 17:51:23 PST 2013
Hello. I'm just getting into D (literally writing my first
program), and I can't figure out how to do this with getopt:
I want to have the option --log, which will enable logging (set a
bool variable to true). However, I want the program to also
accept --log=filename to allow the user to define custom log
file. If --log is used without filename, a default file will be
used.
I tried this:
getopt(args,
"log", &log,
"log", &logFile);
Passing just --log to the program works fine, the boolean is set
to true. However, using --log=test.log throws an exception, and
seemingly getopt expects either true or false.
How would I go about implementing this without creating another
option like --log-file for custom file name?
More information about the Digitalmars-d-learn
mailing list