-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Revamp --query #1187
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
Revamp --query #1187
Conversation
|
Thanks a lot for fixing the lint warnings, @jhheider! @mxcl this is a gentle ping. I'm using a self-built pkgx with this PR ever since I created it, and it's working like a charm. It's probably not perfect, but if you are busy, maybe you can consider merging it and then we can enhance it later. I believe that's ok since it's only really touching the |
|
@felipecrs let me see if i can't get this merged. the only one i don't like is changing the default behavior of the bare |
|
I understand. Breaking changes are never cool. But honestly, I highly doubt there's a person relying on it. mxcl added it upon my request, but IMO its previous behavior never made sense. |
|
But if you really want, I can rework it tomorrow. |
|
my gut says people care more about the programs than what we've named the packages. but if working with the json becomes onerous, i'm not against a flag to give packages. i'm digging into it now. no worries. thanks for getting the ball rolling. |
That specifically doesn't change btw. Users can still query by program. With this PR they can also query by pkg name. |
|
i meant in terms of listing all. but i recognize it can be argued both ways. |
Thanks to @jhheider which merged pkgxdev/pkgx#1187.
Thanks to @jhheider which merged pkgxdev/pkgx#1187.
|
@jhheider thank you so much! This is working like a charm. |
Thanks to @jhheider which merged pkgxdev/pkgx#1187.
Closes #1148
@mxcl, I used Copilot to help me code this.
If you believe the code is not acceptable, feel free to just make changes yourself. There is no need to spend time reviewing this PR. If that's the case, I apologize for it. I'm really not familiar with the codebase and Rust.
I would like to highlight I wanted to reuse more of the existing input args parsing like
+git +git@latest +git-scm.org^1, but I was unable to. That's probably the part which could use most refactoring.Anyway, I changed a little bit how
--queryworks. Let's go through the changes:Unaltered behavior
Allows checking if pkgx can provide some program, and return project name if it can:
Altered behavior
All pkgspecs are now accepted, not only programs:
If version is passed, it is validated to exist too:
When no args are passed, returns all available projects (not programs):
The old behavior was inconsistent (when no args were provided programs were printed, but project was printed when args were provided). The old behavior can still be achieved like this:
New behavior
--json=v2now returns a JSON object with the following structure:The output array follows the order of the arguments passed, and contains the resolved project name and their programs.
Flags can be passed at any position:
Use case
I wrote my bash script to handle pkgx shims levering this new feature:
And it works amazing:
Also, this
pkgsscript is able to recognizepkgxv1 stubs and gracefully refresh them, like when runningpkgs install.Honestly I don't want to keep it forever. The reasons why I wrote my own script are described here.
Someday maybe I will get around to porting it to Rust and maybe you can consider accepting it back. Maybe as some sort of new version of
pkgm, or maybe as a whole new project that is focused on shims, so thatpkgmcan be left focused on "true" installations.