Skip to content

Commit

Permalink
Bail when override toolchain is not installed (#652)
Browse files Browse the repository at this point in the history
  • Loading branch information
alfiedotwtf committed Aug 26, 2024
1 parent 6f0d381 commit 1f2086b
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions src/fuelup_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ use crate::commands::{
toolchain::{self, ToolchainCommand},
upgrade::{self, UpgradeCommand},
};
use crate::ops::{fuelup_show, fuelup_update};
use anyhow::Result;
use crate::{
ops::{fuelup_show, fuelup_update},
toolchain::{DistToolchainDescription, Toolchain},
toolchain_override::ToolchainOverride,
};
use anyhow::{bail, Result};
use clap::Parser;
use std::str::FromStr;
use tracing::info;

#[derive(Debug, Parser)]
#[clap(name = "fuelup", about = "Fuel Toolchain Manager", version)]
Expand Down Expand Up @@ -46,6 +52,26 @@ enum Commands {
pub fn fuelup_cli() -> Result<()> {
let cli = Cli::parse();

if let Some(toolchain_override) = ToolchainOverride::from_project_root() {
let override_path = toolchain_override.cfg.toolchain.channel.to_string();
let toolchain = match DistToolchainDescription::from_str(&override_path) {
Ok(desc) => Toolchain::from_path(&desc.to_string()),
Err(_) => Toolchain::from_path(&override_path),
};

info!("Using override toolchain '{}'", &toolchain.name);

if !toolchain.exists() {
match cli.command {
Commands::Toolchain(_) => {},
_ => bail!(
"Override toolchain is not installed. Please run: 'fuelup toolchain install {}'",
&toolchain.name,
)
}
}
}

match cli.command {
Commands::Check(command) => check::exec(command),
Commands::Completions(command) => completions::exec(command),
Expand Down

0 comments on commit 1f2086b

Please sign in to comment.