Open Samyak2 opened 2 years ago
=
is not valid with short flags, you want -a-10
. Strangely that works, but -a -10
does not.
Ah I see. Well, I think I will stick with long versions for flags that can have negative values.
Thank you making kong, I really like how simple it is to use :heart:
Though, if I may ask
=
is not valid with short flags
Is that a convention? or is it something that kong does not support?
It's a convention from GNU short flags.
I tried this with head
and it correctly parses arguments of the form -a -10
. Both of these work as expected:
echo "hello world" | head -c 5
echo "hello world" | head -c -5
I think Kong should support this form too. What do you think?
Yeah I think it should.
I tried fixing it with this: https://github.com/Samyak2/kong/commit/86d1f36058eb5c30172560250196a28dd9d6e065
It did not work. I don't think that's the right approach as it should only be considered if it's followed by a short flag. Any pointers here?
I have run into this issue, too. I have just ported a utility from Python and argparse to Go and Kong. In the Python version, the utility accepted arguments like -t -1
to indicate infinite tries. Kong is my favorite Go argument parser so far, but this will be a noticeable regression in the CLI if I stick with it.
Minimal reproducible example
The long version works as expected:
The short version:
Errors out:
Context
I did look at https://github.com/alecthomas/kong/issues/166#issuecomment-831497480, but there was no info on whether it is expected that the short and long versions behave differently.
I would be willing to contribute a fix if this is an actual bug.