On Mon, 19 Nov 2007 13:42:15 +0100
Kryz <[EMAIL PROTECTED]> wrote:

> 
> Hello Patrick,
> 
> The logic of the hack is to not allow an option to be put in the  
> command line instead of an argument.
> 
> Elseopt returns an error when a valid option is typed as an argument.
> 
> For now this is done by making an array with the options.
> Opthash check the options and arguments in the command line.
> if there is an arguments we check in the options tab, if its true we  
> return an error message else we continue in the loop.

1 ) Conceptually it's a bit restrictive, 

You may not type :
$ myscript.rb --file -f
which probably means that you cannot use a file '-f'?
You may want this, but maybe sometimes you won't in some scripts. There
should be a switch to enable/disable this feature at parser creation
and/or some way for the user to override it.

2 ) There are some implementation problems.

- You assume that an option may have 2 names like '--file' and '-f', it
is not exact, an option may have n names ( n > 0 !), for instance
'--file', '-f', '--path', '-p' etc.
This should only be checked by the length of the array which describes
an option.

- Moreover, opthash uses getoptlong to parse the command line (which,
for some other reasons, may not be a good idea), getoptlong accepts
unambiguous abbreviations for options, that's to say : in a script
which accepts 2 options '--directory' and '--debug', in place of
'--directory' one may enter '--director', '--directo' ... '--di'.
(I'm not sure it is typically a good idea but it's typically boring to
implement). Therefore, to check for an option name given as an argument,
matching this argument against the names given to opthash is not
sufficient.

I don't know what the urgency of the opthash fix is, it's likely not on
the citical path, thus "il est urgent de tergiverser" and you may first
think of all improvements needed.
I think we should get rid of getoptlong or fix it, it's under the Ruby
licence and there is no legal problem. There some other possible
options like '--' which may stand between options and non-argument
options etc.

-- 
Patrick


--
[email protected]
Unsubscribe: [EMAIL PROTECTED]
Archives: http://lists.else-projects.org/archives/devel
Jabber-MUC: [EMAIL PROTECTED]

Reply via email to