-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlib.rs
53 lines (46 loc) · 1.35 KB
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
mod cli;
mod client;
mod commands;
mod config;
mod interactive;
mod io;
mod progress_reporting;
#[cfg(test)]
mod test_helper;
#[cfg(target_os = "windows")]
// Updater is used only for windows
// Updates for linux and macos are handled
// via package managers
mod updater;
pub use cli::Cli;
use config::TmcCliConfig;
pub use io::{Io, PrintColor};
pub const PLUGIN: &str = "tmc_cli_rust";
pub const PLUGIN_VERSION: &str = env!("CARGO_PKG_VERSION");
pub fn run(cli: Cli, io: &mut Io) {
if let Err(err) = run_inner(io, cli) {
let error_string = format!("{err:#}");
log::error!("{error_string}");
if let Err(err) = io.println(&error_string, PrintColor::Failed) {
println!(
"Failed to print error due to error {err}\nThe underlying error was\n{error_string}"
);
}
}
}
fn run_inner(io: &mut Io, cli: Cli) -> anyhow::Result<()> {
let config_path = TmcCliConfig::location()?;
let config = TmcCliConfig::load(config_path)?;
#[cfg(target_os = "windows")]
let mut config = config;
if cli.no_update {
let os = std::env::consts::OS;
if os == "windows" {
#[cfg(target_os = "windows")]
updater::check_for_update(&mut config, cli.force_update)?;
}
} else {
println!("No Auto-Updates");
}
commands::handle(cli, io, config)
}