[Insight-users] Problem with MetaCommand function: SetOptionComplete()

Subrahmanyam Gorthi subrahmanyam.gorthi at gmail.com
Sat Nov 6 15:04:30 EDT 2010


Dear All,

I am trying to read the command line arguments using "metaCommand.h"
available in ITK.
I am facing problem when I am trying to collect all the information till the
next tag, using the function:
void SetOptionComplete(METAIO_STL::string optionName, bool complete);

Please find below a simple example-code that reproduces my problem:

*The command line input is:*
example.exe -a x1.mhd x2.mhd -o output.mhd -b y1.mhd y2.mhd

*What I expected/wanted as the output from that program is:*
Output file name: output.mhd
First list names:  x1.mhd x2.mhd
Second list names: y1.mhd y2.mhd

*BUT, instead, the output that I got is:*
Output file name: output.mhd
First list names:  x1.mhd x2.mhd
Second list names: x1.mhd x2.mhd y1.mhd y2.mhd

Did I miss something?
*Can you kindly tell me how I should modify the below code so that
I could get my desired output, as mentioned above?*

Thank you in advance for your help.

Warm Regards,
Subrahmanyam Gorthi.

*Here is the code:*

#include<iostream>
#include <string>
#include "metaCommand.h"

int main( int argc, char *argv[] )
{
  MetaCommand command;

  // Output-file-name
  command.SetOption("OutputFile1", "o", true, "Output file name");
  command.AddOptionField("OutputFile1", "fileName1", MetaCommand::STRING,
true);

  // Input list1
  command.SetOption("InputList1", "a", true, "This is the first input
list");
  command.AddOptionField("InputList1", "list1", MetaCommand::STRING, true);
  command.SetOptionComplete("InputList1", true);

  // Input list2
  command.SetOption("InputList2", "b", true, "This is the second input
list");
  command.AddOptionField("InputList2", "list2", MetaCommand::STRING, true);
  command.SetOptionComplete("InputList2", true);

  // Now, Parse the command line
  if (!command.Parse(argc,argv))
    {
    exit( EXIT_FAILURE );
    }

  std::cout << "Output file name:  " <<
command.GetValueAsString("OutputFile1", "fileName1") << std::endl;
  std::cout << "First list names:  " <<
command.GetValueAsString("InputList1", "list1") << std::endl;
  std::cout << "Second list names: " <<
command.GetValueAsString("InputList2", "list2") << std::endl;

  return EXIT_SUCCESS;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20101106/69303ff5/attachment.htm>


More information about the Insight-users mailing list