zyedidia / eget

Easily install prebuilt binaries from GitHub.
MIT License
954 stars 39 forks source link

Improve binary name detection for --upgrade-only #32

Closed dufferzafar closed 2 years ago

dufferzafar commented 2 years ago

Thanks for --upgrade-only. It's a step in the right direction.

However it fails to work when the last component of the repo is different from the binary name.

Case in point:

❯ agrind --version
ag 0.18.0

❯ ls -lah agrind
-rwxr-xr-x 1 szafar infra 140M May 29 20:15 agrind

# The binary is already latest, but eget starts downloading.

❯ eget --upgrade-only rcoh/angle-grinder -a musl
https://github.com/rcoh/angle-grinder/releases/download/v0.18.0/agrind-x86_64-unknown-linux-musl.tar.gz

# This is because it is trying to find a binary called "angle-grinder", which doesn't exist.

# At first I thought, -f would work, but it doesn't
❯ eget --upgrade-only rcoh/angle-grinder -a musl -f agrind
https://github.com/rcoh/angle-grinder/releases/download/v0.18.0/agrind-x86_64-unknown-linux-musl.tar.gz

And now that I think about it, -f should not be used for this functionality.

We could use another switch for it perhaps? -b isn't used yet, -a for asset, -b for binary?

This would help in cases where we rename binaries from the packages, for eg. releases of GDU: https://github.com/dundee/gdu/ usually have binaries with long name like: gdu_linux_amd64_static, which I manually rename to gdu via mv gdu* gdu.

So, I guess for eget, something like this should work: eget --upgrade-only dundee/gdu -a static -b gdu

dufferzafar commented 2 years ago

This can be achieved by using --to with --upgrade-only

eget --upgrade-only rcoh/angle-grinder -a musl -f agrind --to agrind