-
Notifications
You must be signed in to change notification settings - Fork 5
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
Design: allow keys to reference other keys #714
Comments
I see two problems with f-strings:
However, I agree that we need something similar.
With that, your usecases becomes:
This could also allow matching key names (that may be misspelled hence "namespace matching" may not work):
which would get all assets that have a key with "fzj" in its name (and print the values of exactly these keys). |
I agree. They're already learning regex. At the same time, I can't think of any way to add such a feature without adding a new syntax. So it makes sense to use an existing one.
That occurred to me, but then I realized: there are no security issues. The user has crafted a query to run on their own copy of the inventory. Anything they exploit/override is exploiting themselves. So rather, they're being powerful/clever rather than exploitative. They are welcome to do insane/awesome things, and we won't stop them.
Ooooh. Good point. That is interesting. The downside is that we're abusing
Ahh, so you're imagining What if we actually do this the other way around. Currently you're prefixing the keyname with For example:
And
The above is an interesting shorthand, that IMO is valid. It allows avoiding the explicit negation:
What do you think? |
I generally would agree that adding another language/syntax the user needs to know might be problematic. However, in this concrete case I am not sure how far that is true because of:
I know this is not technically an f-string (missing the So from my side a big +1 on the proposed idea of this issue. |
No. While you said you "know it's not", you don't seem to know. f-strings and python format mini language are not the same thing. Which means: No, it's not the same syntax. It just looks similar (in the simplest cases). Which will confuse the hell out of non-programmers. |
I would have said "yes", but then I read further and I think you got a different idea by that phrasing, because:
Nope. The suggested The colon prefix in variable names is a different thing, that happens to use the same character in my proposal. But really, it's: Something enclosed in
Hm. My suggestion was using |
It would be useful if values passed to
onyo set
can refer to other keys in the same asset (i.e. keys should be variables). My initial idea is f-strings.The initial use-cases that inspired this are:
These two use cases are much more important than they initially appear. We give users a lot of power to get data into onyo. But once the data is in onyo, how easy is it to manipulate the assets? Put another way:
The above use-cases can both already be somewhat met by having
onyo get
output all of the data, pipe it intoawk
(for example), and then executeonyo set
. However, even that has limitations. Renaming a key that is a dict would be very effortful.Examples:
Someone has incorrectly assigned inventory numbers to the
serial
field (this relies on #684):Rename a key (especially useful if a dict or list):
Open Questions:
{}
for dictionaries. f-strings also use{}
. Is it possible to clearly differentiate the two?onyo list-keys
#679 ; and ideas around teachingget
andset
about keys)The text was updated successfully, but these errors were encountered: