-
-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can not set negative integer value in command line #117
Comments
Thanks for raising this @ydcool. I can confirm this is still an issue in the latest version: This is related to #101, and is caused by: https://github.com/spf13/pflag/blob/85dd5c8bc61cfa382fecd072378089d4e856579d/flag.go#L962 The code causing this is out of my control (without a PR at least) but in the short term I could introduce a workaround in the form of:
This would mean that throughout dasel, when attempting to parse an int it would check to see if it starts with an I'm going to raise an issue regarding the above and see if I can get the root cause solved. |
The related issue is here: spf13/pflag#311 |
Nice, I'll also keep an eye on it to see if I can help. |
I noticed that # cat /etc/containerd/config.toml | grep '-900'
Usage: grep [OPTION]... PATTERN [FILE]...
Try 'grep --help' for more information.
# cat /etc/containerd/config.toml | grep '\-900'
oom_score = -900 |
On a side note, it seems that escaping the dash does bypass the pflag validation issue, but then the resulting string of Perhaps I could left trim any escape characters when parsing integers. |
I can't just deal with integers here - it's a wider issue. echo '{"items": []}' | dasel put string -p json '.items.[]' '-thing'
Error: unknown shorthand flag: 't' in -thing |
Hey @ydcool, Since this is a wider issue and I'm getting no response from the upstream supporter I've added a echo '{"number":100}' | dasel put int -p json -v -200 '.number' Or in your case: dasel put int -p toml -f /etc/containerd/config.toml -v '-900' '.oom_score' This is currently available on the development build which is accessible via:
go install github.com/tomwright/dasel/cmd/dasel@master
echo '{"name": "Tom"}' | docker run -i --rm ghcr.io/tomwright/dasel:development put int -p json -v '-900' '.age'
{
"age": -900,
"name": "Tom"
} |
|
This is now released under |
Describe the bug
Can not set negative value in command line , it'll treated as a command line flag rather than a value, and the escape character does not work.
To Reproduce
Steps to reproduce the behavior:
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: