I'm writing a C++ application A that calls another application B in the background. Some command line options are for application A, but some should be forwarded to B. Separation should work with a double dash --
.
For example:
./my_executable_A -a --long_b some_file -- -c --long_d
should parse {"-a", "--long_b", "some_file"}
in application A and forward {"-c", "--long_d"}
to application B when it is called by A.
I thought it might make sense to use boost::program_options
for the task, but I didn't find this functionality. Is this possible?
Note: The use case is a libfuse
file system where some of the options are to be forwarded to the fuse_main()
function.
There's no built-in support for that. What I'd recommend is just create an std::vector out of entire argv array, find "--" and if found, slice the vector and pass first part to program_options (which accepts std::vector too) and the second part to your program.