Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.