Skip to main content

romm_cli/
update.rs

1//! Frontend-aware wrappers around [`romm_api::update`] for the CLI binary.
2
3pub use romm_api::update::{
4    open_url_in_browser, ApplyUpdateOptions, ApplyUpdateOutcome, ReleaseComponent, UpdateContext,
5    UpdateStatus,
6};
7
8/// Check for updates using the `romm-cli` crate version and running binary name.
9pub async fn check_for_update() -> anyhow::Result<UpdateStatus> {
10    romm_api::update::check_for_update(UpdateContext::for_running_binary(env!("CARGO_PKG_VERSION")))
11        .await
12}
13
14/// Apply a self-update using the `romm-cli` crate version and running binary name.
15pub async fn apply_update(
16    interrupt: Option<romm_api::core::interrupt::InterruptContext>,
17    options: ApplyUpdateOptions,
18) -> anyhow::Result<ApplyUpdateOutcome> {
19    romm_api::update::apply_update(
20        interrupt,
21        options,
22        UpdateContext::for_running_binary(env!("CARGO_PKG_VERSION")),
23    )
24    .await
25}
26
27pub fn changelog_url() -> &'static str {
28    ReleaseComponent::RommCli.changelog_url()
29}
30
31pub fn open_changelog_in_browser() -> anyhow::Result<()> {
32    romm_api::update::open_changelog_in_browser(ReleaseComponent::RommCli)
33}
34
35pub fn github_api_base_url() -> String {
36    romm_api::update::github_api_base_url()
37}
38
39pub fn github_release_asset_key() -> anyhow::Result<&'static str> {
40    romm_api::update::github_release_asset_key()
41}