ninxsoft / mist-cli

A Mac command-line tool that automatically downloads macOS Firmwares / Installers.
MIT License
620 stars 29 forks source link

Request: Self Update Checking #36

Closed PicoMitchell closed 3 years ago

PicoMitchell commented 3 years ago

While it's not normal for command line tools to auto-update themselves, I think having an update check could be a convenient thing to add to the version output, and/or to check for updates on every non-quiet load and include a note in the verbose output if an update is available.

ninxsoft commented 3 years ago

Generally speaking, command line tools don't self-update, and package managers like Homebrew (#19) make it a point to call this out.

Having said that, I do like the idea of a quick check (on mist version) to see if you are running the latest version.

ninxsoft commented 3 years ago

Perhaps the following, displaying instructions only when mist is out-of-date:

# current
➜ ~ mist version
1.5 (latest: 1.5)

# out-of-date
➜ ~ mist version
1.5 (latest: 1.6)
Visit https://github.com/ninxsoft/mist to grab the latest release of mist

The version will still output on the first line, as the first element in the line, so you could still awk as required to get just the version:

# grep example
➜ ~ mist version | grep latest --max-count 1 | awk '{ print $1 }'
1.5

# head example
➜ ~ mist version | head --lines 1 | awk '{ print $1 }'
1.5
PicoMitchell commented 3 years ago

I've started taking advantage of exit in awk when I only want the first line to avoid having to call a second command like head so just awking the current version could be even easier: mist version | awk '{ print $1; exit }'