On 10.08.2011 1:32, Jens Mueller wrote:
Hi,

I've added some changes to getopt to change when an options is
accepted/rejected. I'm going to describe its old behavior in contrast
with its old behavior.

Consider parsing an option of Type T:

T timeout;
getopt(args, "t|timeout",&timeout);

Short options (single dash):
-t v accept (was rejected)
+1 on this, I recall spending about an hour trying to get why -t v is not working. Though I dunno why change -tv, I think it's widely used form and not only for numerics.
-t=v accept
-tv only accept for numeric v (was accepted for all types except associative 
arrays)
Strange short options:
-timeout v reject
-timeout=v reject (was accepted)
-timeoutv reject
Long options (double dash):
--timeout v accept
--timeout=v accept
--timeoutv reject
Strange long options:
--t v reject (was accepted)
--t=v reject (was accepted)
--tv reject

I would like to know whether you find the new behavior better or if you
prefer the old. Or even a mix of both. Or none of the above.
Like all of the above except -tv.
The current behavior is quite simple if you remember some simple rules:
1. Short options consist of a single dash and a single character.
2. Long options consist of two dashes and more than one character.
3. Passing short and long options is supported by
    <short/long option><space+><value>  and<short/long option>=<value>
4. The form<short option><value>  is only supported for numeric values.
Can't figure out the reason for 4, could you  clarify a bit?
5. Anything else is not supported and an exception is thrown.

To look at the changes see here:
https://github.com/jkm/phobos/commit/b208eeb142ff5a3f189c2595b9800425646b4794 
(fixes old behavior)
https://github.com/jkm/phobos/commit/a25cd2459418d462c85ab14c2d970dd413b4fb05 
(introduces new behavior)

Please comment.

Jens


--
Dmitry Olshansky

Reply via email to