Dear All,<br><br>I am trying to read the command line arguments using "metaCommand.h" available in ITK.<br>I am facing problem when I am trying to collect all the information till the next tag, using the function:<br>
void SetOptionComplete(METAIO_STL::string optionName, bool complete);<br><br>Please find below a simple example-code that reproduces my problem:<br><br><b>The command line input is:</b><br>example.exe -a x1.mhd x2.mhd -o output.mhd -b y1.mhd y2.mhd<br>
<br><b>What I expected/wanted as the output from that program is:</b><br>Output file name: output.mhd<br>First list names: x1.mhd x2.mhd<br>Second list names: y1.mhd y2.mhd<br><br><b>BUT, instead, the output that I got is:</b><br>
Output file name: output.mhd<br>
First list names: x1.mhd x2.mhd<br>
Second list names: x1.mhd x2.mhd y1.mhd y2.mhd<br><br>Did I miss something?<br><b>Can you kindly tell me how I should modify the below code so that<br>I could get my desired output, as mentioned above?</b><br>
<br>Thank you in advance for your help.<br><br>Warm Regards,<br>Subrahmanyam Gorthi.<br><br><b>Here is the code:</b><br><br>#include<iostream><br>#include <string><br>#include "metaCommand.h"<br><br>
int main( int argc, char *argv[] )<br>{<br> MetaCommand command;<br><br> // Output-file-name<br> command.SetOption("OutputFile1", "o", true, "Output file name");<br> command.AddOptionField("OutputFile1", "fileName1", MetaCommand::STRING, true);<br>
<br> // Input list1<br> command.SetOption("InputList1", "a", true, "This is the first input list");<br> command.AddOptionField("InputList1", "list1", MetaCommand::STRING, true);<br>
command.SetOptionComplete("InputList1", true);<br><br> // Input list2<br> command.SetOption("InputList2", "b", true, "This is the second input list");<br> command.AddOptionField("InputList2", "list2", MetaCommand::STRING, true);<br>
command.SetOptionComplete("InputList2", true);<br><br> // Now, Parse the command line<br> if (!command.Parse(argc,argv))<br> {<br> exit( EXIT_FAILURE );<br> }<br><br> std::cout << "Output file name: " << command.GetValueAsString("OutputFile1", "fileName1") << std::endl;<br>
std::cout << "First list names: " << command.GetValueAsString("InputList1", "list1") << std::endl;<br> std::cout << "Second list names: " << command.GetValueAsString("InputList2", "list2") << std::endl;<br>
<br> return EXIT_SUCCESS;<br>}<br><br>