[Toybox] About supporting long(--) option
Rob Landley
rob at landley.net
Mon Apr 29 10:56:17 PDT 2013
On 04/29/2013 01:17:46 AM, Kyungwan Han wrote:
> Hello all,
>
> I have a question about treating long(--) option in toybox.
>
> There are two style options - short(-) and long(--) - in linux system.
> (
> http://unix.stackexchange.com/questions/21852/single-dashes-for-single-character-options-but-double-dashes-for-words
> )
>
> I know toybox supports only short option, so toybox cannot treat
> '--help'
> option.
>
> Is there special reason for not supporting long option?
It does support --longopts, it's just not hugely tested at the moment.
See http://landley.net/toybox/code.html#lib_args and scroll down to
"--longopts".
Long options that alias a short option should work now, just put
(longoptname) after your short option in the option string. You can
even have multiple aliases, ala:
"abc(longforc)(anotherlongforc)#def"
Then "-c42" "--longforc 42" and "--anotherlongforc=42" should all work
the same way. (And yes, the option parsing should understand all those
variants, let me know if it doesn't so I can fix it.)
The design also supports bare longopts (long options which aren't an
alias for a short option) by simply listing them first in the option
string, before any short option to attach to. Unfortunately there's a
bug in lib/args.c (they all get this same bit value, when each should
get a unique bit value), and the header generation logic isn't creating
FLAG_longoptname macros yet so at the moment you can only check for the
ones that alias to a short option you get a macro for.
I need to fix that...
Rob
More information about the Toybox
mailing list