-
Notifications
You must be signed in to change notification settings - Fork 123
How to set a negative value with kdb set #2468
Comments
I think you should take a closer look at the error message 😊:
, which tells you that something like kdb set /user/tests/negative -- -1
#> Using name user/user/tests/negative
#> Set string to "-1" should work. |
Thank you, under this extremely verbose output I did not read that sentence. |
The text could be improved: "see errors above" is misleading, "see lines above" might be better? "If no value is given, it will be set to a null-value" and the following sentence does not have a dot at the end. |
@Piankero what output do you suggest so that you would find the info about |
I am not quite sure if this is possible but if the input was a number, then the text which tells you how to set negative numbers should be arranged at the top. The verbose output of a failed set could only be printed out for every other reason. As I can see there is no number option for kdb set so a solution like this should be fine. Negative number: kdb set '/my/number' '-3'
#> kdb: invalid option -- '3'
#> Did you try to set a negative value? Try 'kdb set -- /tests/neg -3'
#> Sorry, I could not process the given options (see reason above) Anything else: kdb set '/invalid/option' '-a'
#> kdb: invalid option -- 'a'
#> Sorry, I could not process the given options (see errors above)
#>
#> Usage: kdb set <name> [<value>]
#>
#> Set the value of an individual key.
#> If no value is given, it will be set to a null-value
#> To get an empty value you need to quote like "" (depending on shell)
#>
#> -H --help Show the man page.
#> -p --profile <name> Use a different profile for kdb configuration.
#> -v --verbose Explain what is happening.
#> -q --quiet Only print error messages.
#> -V --version Print version info.
#> -N --namespace <ns> Specify the namespace to use for cascading keys.
#> -C --color <when> Print never/auto(default)/always colored output. The reason for this is that settings will be very likely to have negative numbers. Most likely more often than people setting wrong options (which are more easy to debug than negative numbers) |
Thank you for the proposal! This would mean that we would need to check for this situation and yield a different error then. @kodebach is this also easily possible with your command-line parser? I would like to avoid specific code that needs to be thrown after the switch. |
Currently we treat everything starting with While I don't mind changing behaviour to make user interactions more fluent, I don't like going against POSIX standards to do this. One thing that would solve this problem is enabling |
Sorry, in my question it was not clear what "this" is. The proposal is to change the error message in the case somebody uses a |
Changing the error message should be possible as well. It would require modifications, but we could just set some metadata on the parent key, whenever an error is caused by an element of argv. |
Then let us improve the error message for this case! |
I am not sure what I should do here. I can do the following points:
But I honestly do not want to do the complicated stuff that requires enabling posixly and incorporate special error message for different cases depending on the option provided. In retrospective I could have known that negative numbers in terminals always require a Also I have seen that we actually support some sort of numeric parameters too: libelektra/src/tools/kdb/cmdline.cpp Lines 219 to 236 in 2eac612
|
Let us close this issue. The usability is not so bad as the output even says what to do and even gives an example. There is little we can do if people do not even read what is printed. |
How can I set a negative number in kdb?
"
does not help eitherThe text was updated successfully, but these errors were encountered: