View previous topic :: View next topic |
Author |
Message |
baxissimo
Joined: 23 Oct 2006 Posts: 241 Location: Tokyo, Japan
|
Posted: Tue Oct 09, 2007 11:41 pm Post subject: Using positional arguments |
|
|
I'm having trouble understanding how to use positional arguments.
This seems to work:
Code: |
auto po = (new ProgramOptions)
.next(
(new CommandLineStorage(args))
.caption("Command line options:")
.options()
("help,h", "produce help message")
("outdir", define!(string), "set directory for generated output files")
("shapes", define!(string[]).composing, "shape input files names (2)")
("shapes=2", new PositionalOption)
("sync", "stores cmdline options in persistent backend")
("selfname", new SelfName)
()
);
|
However, in the help message there's the cryptic line "shapes=2 interpretation of position's meaning for unmatched option". And it has both that and "--shapes arg" implying that there's only one --shapes argument.
Also the syntax "shapes=2" seems a little odd. It looks like you're setting shapes to be #2 rather than saying there are two positional arguments that take this value. Maybe "shapes[2]" would be a better way to express that. It would also be nice to be able to specify that exactly 2 are required, or <=2, or >2 etc. You can check it yourself, but if ProgramOptions doesn't know what you want then it can't generate a reasonable help message. |
|
Back to top |
|
|
aarti_pl
Joined: 25 Jul 2006 Posts: 28
|
Posted: Fri Oct 12, 2007 3:40 am Post subject: |
|
|
Quote: |
However, in the help message there's the cryptic line "shapes=2 interpretation of position's meaning for unmatched option". And it has both that and "--shapes arg" implying that there's only one --shapes argument.
|
Message for positional option is just a default one. You can set your own in positional option definition:
e.g. ("shapes=2", "your description", new PositionalOption)
But of course default description probably is not best. Better suggestion is welcomed
The second form is because you still can use it in a following way:
--shapes=circle,triangle,square
and it will work as expected.
Quote: |
Also the syntax "shapes=2" seems a little odd. It looks like you're setting shapes to be #2 rather than saying there are two positional arguments that take this value. Maybe "shapes[2]" would be a better way to express that.
|
It was easy to parse, but yes, I think that there might be a better way to express this. I don't like very much '[2]' syntax.
Maybe it would be better to have:
("2*shapes, 3*names, path", "your description", new PositionalOption)
?
Quote: |
It would also be nice to be able to specify that exactly 2 are required, or <=2, or >2 etc. You can check it yourself, but if ProgramOptions doesn't know what you want then it can't generate a reasonable help message.
|
Probably something like this:
("2*shapes[r], 3*names, 1*path[r], path", "your description", new PositionalOption)
Uff... it's getting complicated... Maybe it will be too complicated and gain will be not that big? I will think about it some more... |
|
Back to top |
|
|
baxissimo
Joined: 23 Oct 2006 Posts: 241 Location: Tokyo, Japan
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|