Bug 1653

Summary: Extension of CommandLine interface
Product: ns-3 Reporter: Alex Afanasyev <alexander.afanasyev>
Component: coreAssignee: Alex Afanasyev <alexander.afanasyev>
Status: RESOLVED FIXED    
Severity: normal CC: ns-bugs, pdbarnes, tomh, tommaso.pecorella
Priority: P5    
Version: ns-3-dev   
Hardware: All   
OS: All   
Attachments: Patch
Patch
Fixup of previous patch

Description Alex Afanasyev 2013-04-26 18:20:55 UTC
Created attachment 1574 [details]
Patch

The attached patch extends CommandLine interface and allows requesting output of command line arguments help message using a couple of alternative methods.
Comment 1 Mathieu Lacage 2013-04-30 09:24:55 UTC
(In reply to comment #0)
> Created attachment 1574 [details]
> Patch
> 
> The attached patch extends CommandLine interface and allows requesting output
> of command line arguments help message using a couple of alternative methods.

ok, +1 for merging.
Comment 2 Tommaso Pecorella 2013-06-16 08:05:34 UTC
I didn't understand the changes to be honest. I mean, I'm ok with it but I couldn't find the "couple of alternative methods"
Comment 3 Alex Afanasyev 2013-07-27 18:51:18 UTC
Created attachment 1648 [details]
Patch

Updated patch against the most recent changes in command-line.h|cc

The basic desire originally was (and still is) to be able to print out help message, in case scenario detects incompatible command-line arguments (rather than just exiting with just error message).  There are two basic changes:

1. Moving PrintHelp to public section of the class
2. Changing prototype of all Print* functions to accept output stream as a first argument and then implementing an overloaded operator>>.

By "a couple methods" I meant just "cmd.PrintHelper (std::cout)" and "std::cout << cmd", but I agree this was a little bit confusing :)
Comment 4 Tom Henderson 2013-07-28 15:45:38 UTC
(In reply to comment #3)
> Created attachment 1648 [details]
> Patch
> 
> Updated patch against the most recent changes in command-line.h|cc
> 
> The basic desire originally was (and still is) to be able to print out help
> message, in case scenario detects incompatible command-line arguments (rather
> than just exiting with just error message).  There are two basic changes:
> 
> 1. Moving PrintHelp to public section of the class
> 2. Changing prototype of all Print* functions to accept output stream as a
> first argument and then implementing an overloaded operator>>.
> 
> By "a couple methods" I meant just "cmd.PrintHelper (std::cout)" and "std::cout
> << cmd", but I agree this was a little bit confusing :)


Does your documentation of PrintHelp() need updating, to match the commit message?

Also, is it operator >> or insertion operator<< ?

+   * Alternatively, an overloaded operator >> can be used:
+   * @code
+   *       CommandLine cmd;
+   *       cmd.Parse (argc, argv);
+   *     ...
+   *     
+   *       std::cerr << cmd;
+   * @endcode   
+   */

Is this something that should be patched into the tutorial and one or more examples?
Comment 5 Alex Afanasyev 2013-07-28 16:10:32 UTC
Created attachment 1649 [details]
Fixup of previous patch

Oops. My mistake.  Uploaded the corrected commit with corrected documentation of PrintHelp and similar documentation for operator<<.

Are you suggesting to make a new example or modify some existing example to show potential usage?
Comment 6 Tom Henderson 2013-07-29 00:40:46 UTC
(In reply to comment #5)
> Created attachment 1649 [details]
> Fixup of previous patch
> 
> Oops. My mistake.  Uploaded the corrected commit with corrected documentation
> of PrintHelp and similar documentation for operator<<.
> 
> Are you suggesting to make a new example or modify some existing example to
> show potential usage?

Yes, I was just suggesting to feel free to extend the tutorial or example in an appropriate place; many people only learn about features they see in the tutorials or examples.

I'll plan to push this later this week if there are no other comments.
Comment 7 Tom Henderson 2013-08-14 02:20:14 UTC
changeset 48f66512ec9b
Comment 8 Alex Afanasyev 2013-11-01 17:30:15 UTC
I noticed that one of the commits (http://code.nsnam.org/ns-3-dev/rev/5f6bab1bf0f4) undoes some of the previously added functions. In particular, it removes overloaded operator<< for CommandLine.

Is there a particular reason for this removal or is just an accident?
Comment 9 Peter Barnes 2014-02-21 01:01:36 UTC
operator << (std::ostream, CommandLine0 restored in patch r10621 
http://code.nsnam.org/ns-3-dev/rev/c23778df1349