Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show a message if a newer version is available #249

Open
beardgans opened this issue Apr 18, 2022 · 5 comments
Open

Show a message if a newer version is available #249

beardgans opened this issue Apr 18, 2022 · 5 comments

Comments

@beardgans
Copy link

馃憢 Thank you for this awesome project!

I found this feature in the GitHub CLI application and npm.

I think it'll be useful for users who install xh using the installation script or cargo.
And this will let them know that a new version is available and it's time to update.

Ready-made crates to implement that:

@ducaale
Copy link
Owner

ducaale commented Apr 18, 2022

Thanks for the suggestion. Do you know of any other CLI tool that checks for updates in the background? I thought npm, github-cli and ngrok were unique cases in that they need to be up to date to keep up with their backing server. However, for tools installed via an installation script, perhaps a dedicated update-checker tool would be more ideal?

@beardgans
Copy link
Author

Do you know of any other CLI tool that checks for updates in the background? However, for tools installed via an installation script, perhaps a dedicated update-checker tool would be more ideal?

No, I don't know such CLI tools.

However, for tools installed via an installation script, perhaps a dedicated update-checker tool would be more ideal?

I'm not sure because I can't imagine how it could be 馃

@blyxxyz
Copy link
Collaborator

blyxxyz commented Apr 20, 2022

(EDIT: I wrote the below thinking this was about an updater, not just a notifier, so some of it doesn't apply.)

I definitely wouldn't want xh to check for updates on its own accord.

A builtin updater you call manually might be reasonable, but it wouldn't be straightforward.

  • We already have reqwest and serde-json, so we can roll our own solution without adding dependency bloat.
  • We wouldn't want it included in distro builds.
  • For installations done through cargo install we'd probably also want to leave it out. At most a notifier.
  • We'd have to take care with permissions, xh might be installed as root with the updater running as a user.
  • IIRC Windows doesn't let you replace an executable while it's running, and macOS may also have something like that.
  • The new version should not have different feature flags (i.e. native-tls).
  • I personally don't like it when this is built into tools. I prefer package managers so you don't have to update a million programs in a million different ways.

@ducaale
Copy link
Owner

ducaale commented Apr 20, 2022

I'm not sure because I can't imagine how it could be 馃

I was thinking of a tool that uses either update-informer or update-notifier to check for updates before spawning the command it received as the first argument

$ update-checker xh httpbin.org/json
---------------------------------------
New version of xh is available: v0.17.0
---------------------------------------
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Content-Length: 429
Content-Type: application/json
Date: Wed, 20 Apr 2022 22:49:04 GMT
Server: gunicorn/19.9.0

{
    "slideshow": {
        "author": "Yours Truly",
        "date": "date of publication",
        "slides": [
            {
                "title": "Wake up to WonderWidgets!",
                "type": "all"
            },
            {
                "items": [
                    "Why <em>WonderWidgets</em> are great",
                    "Who <em>buys</em> WonderWidgets"
                ],
                "title": "Overview",
                "type": "all"
            }
        ],
        "title": "Sample Slide Show"
    }
}

# avoid typing update-checker by aliasing it to the command that needs to be up to date
$ alias xh="update-checker xh"

Basic configuration needed by update-checker

# update-checker.toml

[xh]
version = "xh -V"
repo = "ducaale/xh"

[rg]
version = "rg -V"
repo = "BurntSushi/ripgrep"

You can then add an interactive setup to the update-checker that takes care of aliasing + updating the config file.

@psychonaut
Copy link

psychonaut commented Apr 24, 2022

terraform does that when you use 'terraform version'

$ terraform version
Terraform v1.1.3
on linux_amd64

Your version of Terraform is out of date! The latest version
is 1.1.9. You can update by downloading from https://www.terraform.io/downloads.html

Personally, I am using cargo install-update from time to time and this works the best for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants