Crate updater_lp

source ·
Expand description

updater-lp

A no frills updater that uses Github has its base. Easily create auto-updating for your cli apps!

How it Works?

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.

How to use it.

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.

Include the library

Add updater-lp to your cargo.toml.

[dependencies]
updater-lp = "0.2"

Using the Library

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.

A note of Versions

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

Functions

A passthrough for the version-lp crate, so you can create a version to compare against.
A passthrough for the version-lp crate, so you can create a version to compare against.
Checks the given Repository for the latest version
Checks the given Repository for the latest compatible release.
Checks the given Repository for the compatible release of the given version.
Updates the current application from the provided link.
Update the application with the specific version from the Repository.