In the CommandLine parser there is a way to specify that a command line option is required. Is there a way to specify that the option is required only if some other option is set?
In particular, I want to build a transformation T that opt loads. So, I when I register T with opt a boolean command line option is created. If the option is set by the user, then the transformation is run. However, T requires the user to specify the names of some files. So, I can use cl::opt<string> to create command line options F1, F2, and F3 with which the user can specify those file names. If I define F1, F2, and F3 as cl::required, they are required even if transform T is not being run. Is there a way to make the file command line arguments required contingent on the presence of transform T's command line flag?
Thanks in advance,
Ryan
Ryan,
Did you read this: http://llvm.org/docs/CommandLine.html#valrequired ?
In the CommandLine parser there is a way to specify that a command line
option is required. Is there a way to specify that the option is
required only if some other option is set?
I don't think it currently handles this, although something like
"cl::MustFollow(OtherOption)" could be added. Alternatively, you could
provide a custom parser.
In particular, I want to build a transformation T that opt loads. So, I
when I register T with opt a boolean command line option is created. If
the option is set by the user, then the transformation is run. However,
T requires the user to specify the names of some files. So, I can use
cl::opt<string> to create command line options F1, F2, and F3 with which
the user can specify those file names. If I define F1, F2, and F3 as
cl::required, they are required even if transform T is not being run.
Is there a way to make the file command line arguments required
contingent on the presence of transform T's command line flag?
Not that I know of. However, it would probably be acceptable to make
them optional and emit an error if they aren't given when -T is
specified.
Reid.