Crates.io | updater-lp |
lib.rs | updater-lp |
version | 0.3.0 |
source | src |
created_at | 2018-12-17 01:56:13.876705 |
updated_at | 2018-12-17 22:49:41.241699 |
description | a library to easily make cli apps with an auto-updater. |
homepage | |
repository | https://github.com/snsvrno/updater-lp-rs |
max_upload_size | |
id | 102255 |
size | 22,318 |
A no frills updater that uses Github has its base. Easily create auto-updating for your cli apps!
Host your code on Github! Tag your code with version releases and then attach builds to those releases.
updater-lp then looks for the release at your repository and then version matches those release against what you state your current app version is. If it finds a newer version, it can be used to 'update' your app by replacing your current binary with the new binary from Github.
First off, a test app is in the source repository that shows you how its used, as well as is used to test the libraries functionality.
Add updater-lp to your cargo.toml
.
[dependencies]
updater-lp = "0.2"
Then you need to set your upstream address. updater-lp is struct-less (or better called static)
so its recommended you have a &'STATIC str
with your repository address.
static REPO_PATH : &str = "https://github.com/snsvrno/lpsettings-rs";
And then where ever it makes sense, you should check for the latest version. I'd recommend putting someting to prevent checking everytime the program runs (so you don't perform too many needless github api calls) and instead check for updates daily.
let this_version = updater_lp::create_version(&[01,2,3,4]);
match updater_lp::get_latest_version(REPO_PATH) {
Err(error) => {
// can't check the version for some reason, `error` should state why.
},
Ok(latest) => {
if latest > this_version {
updater_lp::update_with_version(REPO_PATH,&latest);
}
}
}
I'd recommend against using ?
on get_latest_version
because you probably don't want your program
error / fail if you can't connect to the repo.
updater-lp uses version-lp for all versions. This means
that versions are easily compairable. Version is exposed in this crate to allow for easy use
without requiring you to add an additional dependency to your cargo.toml