use super::Command;
use crate::{
cmd::{self, exec},
env::*,
error, shell, warning,
};
use clap::Args;
#[derive(Args)]
#[command(visible_aliases = ["c"])]
pub struct Current;
impl Command for Current {
fn run(&self) -> anyhow::Result<()> {
check_env_applied(&shell::get_shell())?;
if let Some(v) = get_current_version()? {
println!("{v}");
return Ok(());
}
warning!("No version installed via goup");
match exec(&["go", "version"]) {
Ok(v) => println!("from system: {v}"),
Err(cmd::errors::Error::NotFound) => {
error!("no local go version found");
}
Err(err) => return Err(err.into()),
}
Ok(())
}
}