I am using boost::program_options
to parse my command line. Now, I am adding support for batch execution, by means of a --script
argument denoting a file, containing command line options on every line, for instance:
--src="\"z:\dev\veds\sqlexpress\Run 1.ved\"" --src-kind=bla --yz
--src=z:\dev\veds\sqlexpress\db.ebf
--src=z:\dev\veds\sqlexpress\db2.mdf
--src=db3
--src="\"z:\dev\veds\sqlite\Run 41 (Run 23).ved\""
--src=z:\dev\veds\sqlite\ws_results_db_2012_01_15_18_37_03.db3
--src=z:\dev\veds\mysql\10.ved
--src=z:\dev\veds\mysql\db
Each line in the file denotes a single execution of my tool and lists the command line options for this particular execution.
The problem is that reading the script file yields complete lines, which are not broken into individual command line options. But, one has to have argc
and argv
in order to use boost::program_options
, i.e. it depends on someone to break the command line into different options.
I cannot simply break by spaces, because some values contain spaces and hence they are enclosed with double quotes, even nested double quotes.
On the other hand, I do not want to run the tool from the OS command prompt for each set of command line options, because of the expensive bootstrap - the reason why I am introducing the script feature in the first place.
Is there a simple way to break the lines into the command line arguments in the same way the OS does it?
Thanks.