Ok, I found an issues...

- If no short options are passed in param, this will lamentably crash
if passing such an option in the command line (ex: myapp -f).

What about a redesign of TOption array to also include the single-char
switch of a long option (replacing the 'value' field). So the match
would be simple to do. When calling the GetLongOpts function, the list
of long options would be parsed to extract the single-char switch
equivalent then would be added to the actual short switches. It avoids
duplicating and mixing switches.

Example:

 with opts[0] do //-f filename --file filename
 begin
   name := 'file';
   short := 'f';     /////////new short option
   has_arg := 1;
   flag := nil;
///    value := 'f'; //becomes useless
 end;
 with opts[1] do //-u 123 --userid 123
 begin
   name := 'userid';
   short := 'u';     /////////new short option
   has_arg := 1;
   flag := nil;
///    value := 'u'; //becomes useless
 end;

Then calling:
   c := GetLongOpts('z', @opts[0], index);

Would give the same result as actual:
   c := GetLongOpts('f:u:z', @opts[0], index);

The problem actually is that you better be carefull not to change the
arguments order. If this is not the intention of the original author
(Michael) or other coders, tell me so.

--
Alexandre Leclerc

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to