-
Notifications
You must be signed in to change notification settings - Fork 510
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
add 'json_stringify' and 'jaq' (jq) built-in functions #2557
Comments
Just has a very strong backwards compatibility guarantee, so I don't think we could expose something like We would probably either wind up having to use an unmaintained, older version, have to make a backwards incompatible change upgrading to a new version. That being said, can you give some example concrete use cases? I want to understand what this provides. |
Hm, would that same argument then apply to any external library that exposes a syntax defined by that library? If so, isn't most of the discussion in #2532 also moot? In any case, wouldn't it still be possible that it is easier/better to incorporate something mature (the original /~https://github.com/jqlang/jq has been around for a while, I am not aware of any time that either jq or jaq has made a backward-incompatible change, and both have been quite heavily tested), but anyway incorporating a snapshot wouldn't be any different from what Apple did with a bunch of BSD code. |
Sure, we could look at how this could be used as an alternative to the self-described "not very elegant"
With json_stringify and jaq, the result is possibly a bit more elegant, and is fully shell-less (at least for the looping logic):
(Note that the above assumes that the "--raw" output flag is set which is missing the diff code I posted earlier) |
Yes, definitely. For example, we use the In the case of #2532, the draft PR I have open for it adds simple shell parsing that we implement, so no external dependencies. And if there was a very mature Rust bourne shell implementation, whose goal was POSIX compatibility, I think I would be more comfortable with it, since it feels like less of a moving target than a
The example you gave is interesting. I could see adding |
I suppose you could say that about every library down to compression, SSL etc. At some point it takes more work to build and maintain homegrown code than someone else's code. But I understand that as the maintainer you have to be vigilant in keeping your yard to a manageable size. An alternative, which I'm guessing is the direction you are going, is to avoid expanding the expression grammar and reduce everything to functions. However, doing so might make it very difficult to support a meaningful level of versatility. Alternatively, a home-grown expression language isn't very hard, but you then choose between a) asking your users to learn yet-another expression syntax that differs from what they already know, or b) borrowing some pre-existing expression syntax in which case, if you don't re-use the original library that supported that syntax, you just end up duplicating some existing code base, which isn't very different from picking a version of an existing code base and internalizing it. (as an aside, I hope you know I'm truly not trying to be argumentative here, just hoping to both expand the utility of this project (for my selfish purposes) in a manner that minimizes the short- and long-term burden, and so for that latter purpose, am describing what I truly believe will be the least burdensome and most value add. But I totally get that I'm not the one maintaining, I don't have the historical context to be in a credible position to opine, and it's not at all my call anyway)
Sounds good, thanks for considering and lmk if I can do anything to help! |
So I just did a little experiment by adding two functons to my own just repo:
json_stringify()
andjaq()
(rust implementation of jq)They worked fabulously. I would like to propose incorporating them into the official
just
.These alone can fill a huge portion of the gap that is needed to make a no-shell option viable (in fact, that's what I used them for), such as #1570 and #2458, as well as related use cases discussed in #528, #537, #2379, #2080, and probably many others.
Granted, using jq is a particular approach that may or may suit the user and for any given case might not be the perfect choice compared with potential external alternatives-- but consider:
Thoughts?
FYI, the changes in function.rs were merely as follows (note: this is a super quick-and-dirty whip-up for illustrative purposes). Happy to submit a PR:
The text was updated successfully, but these errors were encountered: