Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print warning if there is no toolchain to update #573

Merged
merged 4 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ name = "fuelup"
path = "src/main.rs"

[dependencies]
ansi_term = "0.12.1"
ansiterm = "0.12.2"
anyhow = "1"
clap = { version = "4.2.4", features = ["cargo", "derive", "env"] }
Expand Down
10 changes: 9 additions & 1 deletion src/fmt.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
use crate::target_triple::TargetTriple;
use ansi_term::Colour;
use ansiterm::Style;
use tracing::info;

use crate::target_triple::TargetTriple;
pub fn println_error<X: Into<String>>(txt: X) {
tracing::warn!("{}: {}", Colour::Red.paint("error"), txt.into());
}

pub fn println_warn<X: Into<String>>(txt: X) {
tracing::warn!("{}: {}", Colour::Yellow.paint("warning"), txt.into());
}

pub fn bold(text: &str) -> String {
let style = Style::new().bold();
Expand Down
9 changes: 8 additions & 1 deletion src/ops/fuelup_update.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
channel::Channel,
config::Config,
fmt::{bold, colored_bold},
fmt::{bold, colored_bold, println_error},
path::warn_existing_fuel_executables,
toolchain::{DistToolchainDescription, Toolchain},
};
Expand All @@ -20,6 +20,13 @@ pub fn update() -> Result<()> {

warn_existing_fuel_executables()?;
crodas marked this conversation as resolved.
Show resolved Hide resolved

if toolchains.is_empty() {
println_error(
"No toolchains are installed. Use `fuelup default <toolchain>` to install a toolchain.",
);
return Ok(());
}

for toolchain in toolchains {
let mut installed_bins = String::new();
let mut errored_bins = String::new();
Expand Down
14 changes: 3 additions & 11 deletions src/path.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
use crate::{constants::FUEL_TOOLCHAIN_TOML_FILE, fmt::println_warn};
use anyhow::{bail, Result};
use component::Components;
use dirs;
use std::env;
use std::{
fs,
path::{Path, PathBuf},
};
use tracing::warn;

use dirs;

use crate::constants::FUEL_TOOLCHAIN_TOML_FILE;

pub const FUELUP_DIR: &str = ".fuelup";
pub const FUELUP_HOME: &str = "FUELUP_HOME";
Expand Down Expand Up @@ -76,8 +73,6 @@ pub fn warn_existing_fuel_executables() -> Result<()> {
vec![]
}

let mut summary = String::new();

for c in components {
for e in c.executables {
if let Some(path) = search_directories()
Expand Down Expand Up @@ -119,15 +114,12 @@ pub fn warn_existing_fuel_executables() -> Result<()> {
}

if !message.is_empty() {
summary.push_str(&message);
summary.push('\n');
println_warn(message);
}
}
}
}

warn!("{}", summary);

Ok(())
}

Expand Down
Loading