groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Groff] Re: getopt() as gtroff macro ?


From: Keith Marshall
Subject: Re: [Groff] Re: getopt() as gtroff macro ?
Date: Sun, 26 Sep 2004 09:54:49 +0100

On Friday 24 September 2004 3:44 pm, Werner LEMBERG wrote:
> > both the long or the short ones (one could choose between
> > readability and conciseness).  Flags would always be numeric
> > (essentially boolean) and options with values would always return a
> > string, which if numeric would require a unit designator (as above).
> > If the string is used in a numeric context, it would be converted to
> > that first:
>
> Maybe a synthesis of a function call for error handling and register
> assignments is the way to go.  Here another try, incorporating your
> ideas:
>
>   .getopt <prefix> <options> <long options> <arguments>
>
> Example:
>
>   .de foo
>   .  getopt "foox" "ac:" "--all --check=" \\$@
>   .  ...
>   ..
>
> The .getopt command would do
>
>   .ds <prefix><option> <argument>    \" option with argument
>   .nr <prefix><option> 1             \" option without argument
>
> It will call the function `<prefix>-?' (with <option> as the argument)
> if <option> is invalid.  Finally, it will apply a proper `.shift' call
> so that after .getopt parameter \$1 is the first non-option argument.
>
> Calling the above function like this
>
>   .foo -a -c bar --all --check=urgh --xxx arg1 arg2
>
> would consequently do the following assignments
>
>   .nr foox-a 1
>   .ds foox-c bar
>   .nr foox--all 1
>   .ds foox--check urgh
>
> and this macro call:
>
>   .foox-? --xxx

IMHO, this should satisfy all reasonable requirements.  Lets go for it!!!

Best regards,
Keith.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]