nimbus_cli/updater/
mod.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
5mod taskcluster;
6
7use console::Term;
8
9pub(crate) fn check_for_update() {
10    if std::env::var("NIMBUS_CLI_SUPPRESS_UPDATE_CHECK").is_ok() {
11        return;
12    }
13    taskcluster::check_taskcluster_for_update(|curr, next| {
14        let term = Term::stderr();
15        let txt_style = term.style().green();
16        let cmd_style = term.style().yellow();
17
18        _ = term.write_line(&format!(
19            "{}",
20            txt_style.apply_to(format!("An update is available: {} --> {}", curr, next))
21        ));
22
23        _ = if std::env::consts::OS != "windows" {
24            term.write_line(&format!("{}\n{}",
25                txt_style.apply_to("To update, run this command:"),
26                cmd_style.apply_to("  curl https://raw.githubusercontent.com/mozilla/application-services/main/install-nimbus-cli.sh | bash")
27            ))
28        } else {
29            term.write_line(&format!("{}",
30                txt_style.apply_to("To update follow the instructions at https://experimenter.info/nimbus-cli/install")
31            ))
32        };
33    });
34}