use std::process;
use clap::Command;
use colored::*;
use log::{error, info};
use crate::utils::display::print_unicode_box;
use crate::utils::download::download_binary;
use crate::utils::stackql::get_version;
pub fn command() -> Command {
Command::new("upgrade").about("Upgrade stackql to the latest version")
}
pub fn execute() {
print_unicode_box(
"Installing or upgrading stackql...",
crate::utils::display::BorderColor::Yellow,
);
match download_binary() {
Ok(path) => {
match get_version() {
Ok(version_info) => {
info!(
"Successfully installed the latest stackql binary, version ({}) at: {}",
version_info.version,
path.display().to_string().green()
);
}
Err(e) => {
error!("Failed to get stackql version: {}", e);
}
}
}
Err(e) => {
error!("Error upgrading stackql binary: {}", e);
process::exit(1);
}
}
}