Skip to content

Commit 1f2086b

Browse files
committed
Bail when override toolchain is not installed (#652)
1 parent 6f0d381 commit 1f2086b

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

src/fuelup_cli.rs

+28-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,15 @@ use crate::commands::{
77
toolchain::{self, ToolchainCommand},
88
upgrade::{self, UpgradeCommand},
99
};
10-
use crate::ops::{fuelup_show, fuelup_update};
11-
use anyhow::Result;
10+
use crate::{
11+
ops::{fuelup_show, fuelup_update},
12+
toolchain::{DistToolchainDescription, Toolchain},
13+
toolchain_override::ToolchainOverride,
14+
};
15+
use anyhow::{bail, Result};
1216
use clap::Parser;
17+
use std::str::FromStr;
18+
use tracing::info;
1319

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

55+
if let Some(toolchain_override) = ToolchainOverride::from_project_root() {
56+
let override_path = toolchain_override.cfg.toolchain.channel.to_string();
57+
let toolchain = match DistToolchainDescription::from_str(&override_path) {
58+
Ok(desc) => Toolchain::from_path(&desc.to_string()),
59+
Err(_) => Toolchain::from_path(&override_path),
60+
};
61+
62+
info!("Using override toolchain '{}'", &toolchain.name);
63+
64+
if !toolchain.exists() {
65+
match cli.command {
66+
Commands::Toolchain(_) => {},
67+
_ => bail!(
68+
"Override toolchain is not installed. Please run: 'fuelup toolchain install {}'",
69+
&toolchain.name,
70+
)
71+
}
72+
}
73+
}
74+
4975
match cli.command {
5076
Commands::Check(command) => check::exec(command),
5177
Commands::Completions(command) => completions::exec(command),

0 commit comments

Comments
 (0)