Bug 2461 - CommandLine should handle non-option arguments
CommandLine should handle non-option arguments
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: core
ns-3-dev
All All
: P5 enhancement
Assigned To: Peter Barnes
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-08-05 19:51 EDT by Peter Barnes
Modified: 2018-04-05 20:34 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Barnes 2016-08-05 19:51:51 EDT
CommandLine only supports long-form flags: "--arg" and "--arg=x"

It should also support nonoption (positional) arguments, which don't have the leading "--", and must occur in a specified order:

$ foo arg1 --flag1 arg2 --flag2=x

Suggest adding API:

template <typename T>
CommandLine::AddNonOption (std::string name, std::string help, T & value)

The name string is used when printing the Usage message; the other args are as for AddValue.

CommandLine would keep a vector of non-option arguments, and a counter of how many had been seen so far.  It would probably be helpful to the user to query how many were seen:  int CommandLine::GetNNonOption ()

(The term non-option is as used by the getopt() and getop_long() man pages.)
Comment 1 Peter Barnes 2018-04-05 20:34:14 EDT
Pushed in r13466 (daa91474)