View Issue Details

IDProjectCategoryView StatusLast Update
0001269Slicer4Core: Base Codepublic2014-05-13 09:06
ReporterfinetjulAssigned Tojcfr 
PrioritylowSeverityfeatureReproducibilityN/A
Status feedbackResolutionopen 
Product Version 
Target VersionFixed in Version 
Summary0001269: 1 function call for 1 argument to parse argc/argv with ctkCommandLineParser
Description

Right now, to parse a command line, it requires minimum 4 lines of codes.

If you are only interested with 1 argument, it could be handy to have 1 function (static?) to test if an argument is passed in the commandline.
e.g.
bool ctkCommmandLineParser::testArgument(int argc, char* argv[], const QString& arg);

void main(int argc, char* argv[])
{
if ( ctkCommmandLineParser::testArgument(argc, argv, "--enable-feature"))
{
// enable feature
}
}

Additional Information

While we are at it, it could also be handy if it could memorize the parsing (like strtok() does):
void main(int argc, char* argv[])
{
if ( ctkCommmandLineParser::testArgument(argc, argv, "--enable-feature"))
{
// enable feature
}
if ( ctkCommmandLineParser::testArgument(argc, argv, "--enable-other-feature"))
{
// enable other feature
}
}
It's probably not feasible, but it would be a very user-friendly API.

TagsNo tags attached.

Activities

jcfr

jcfr

2012-02-06 18:23

administrator   ~0003602

See https://github.com/jcfr/CTK/commit/2ecff9ba18186ad0cc3a57d04c57d85fa1592e25

jcfr

jcfr

2014-03-07 11:07

administrator   ~0011383

Let me know if the approach implemented in this topic works for you.
See https://github.com/jcfr/CTK/tree/add-simple-command-line-parser

Issue History

Date Modified Username Field Change
2011-07-08 23:31 finetjul New Issue
2011-07-08 23:31 finetjul Status new => assigned
2011-07-08 23:31 finetjul Assigned To => jcfr
2012-02-06 18:23 jcfr Note Added: 0003602
2012-08-21 12:04 jcfr Target Version => Slicer 4.3.0
2013-08-30 19:20 jcfr Target Version Slicer 4.3.0 => Slicer 4.4.0
2014-03-07 11:05 jcfr Status assigned => acknowledged
2014-03-07 11:05 jcfr Target Version Slicer 4.4.0 =>
2014-03-07 11:06 jcfr Status acknowledged => assigned
2014-03-07 11:06 jcfr Target Version => Slicer 4.4.0
2014-03-07 11:07 jcfr Note Added: 0011383
2014-03-07 11:07 jcfr Status assigned => feedback
2014-05-13 09:06 jcfr Target Version Slicer 4.4.0 =>