Skip to content
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
4 changes: 2 additions & 2 deletions src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ pub fn parse_version_spec(spec: Option<String>) -> Result<(String, Option<String
}
}

pub fn print_table(binaries: &Vec<BinaryVersion>) {
let mut binaries_vec = binaries.clone();
pub fn print_table(binaries: &[BinaryVersion]) {
let mut binaries_vec = binaries.to_owned();
// sort by Binary column
binaries_vec.sort_by_key(|b| b.binary_name.clone());
let mut table = Table::new();
Expand Down
2 changes: 1 addition & 1 deletion src/component/doctor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::process::Command;

pub async fn run_doctor_checks() -> Result<()> {
println!("\n{}", "Suiup Environment Doctor".bold());
println!("{}", "------------------------");
println!("------------------------");

let mut warnings = 0;
let mut errors = 0;
Expand Down
5 changes: 2 additions & 3 deletions src/handlers/cleanup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub async fn handle_cleanup(all: bool, days: u32, dry_run: bool) -> Result<()> {
fs::remove_dir_all(&release_archive_dir)?;
fs::create_dir_all(&release_archive_dir)?;
}
println!("{}", "Cache cleared successfully.");
println!("Cache cleared successfully.");
}
return Ok(());
}
Expand Down Expand Up @@ -100,8 +100,7 @@ pub async fn handle_cleanup(all: bool, days: u32, dry_run: bool) -> Result<()> {
);
} else {
println!(
"{} {} files removed, {} freed",
"Cleanup complete.",
"Cleanup complete. {} files removed, {} freed",
files_removed,
format_file_size(cleaned_size)
);
Expand Down
4 changes: 2 additions & 2 deletions src/handlers/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ pub async fn install_standalone(
let network = "standalone".to_string();
let binary_name = repo.binary_name();
if !check_if_binaries_exist(
&binary_name,
binary_name,
network.clone(),
&version.clone().unwrap_or_default(),
)? {
Expand All @@ -186,7 +186,7 @@ pub async fn install_standalone(
.join(&network)
.join(format!("{}-{}", binary_name, installed_version));
install_binary(
&binary_name,
binary_name,
network,
&installed_version,
false,
Expand Down
8 changes: 6 additions & 2 deletions src/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub fn update_after_install(
binary.clone()
};

let mut binary_path = if version == "nightly" {
let binary_path = if version == "nightly" {
// cargo install places the binary in a `bin` folder
binaries_dir()
.join(&network)
Expand All @@ -100,6 +100,8 @@ pub fn update_after_install(
.join(format!("{}-{}", binary_name, version))
};

#[cfg(windows)]
let mut binary_path = binary_path.clone();
#[cfg(windows)]
{
if binary_path.extension() != Some("exe".as_ref()) {
Expand Down Expand Up @@ -173,10 +175,12 @@ pub fn update_after_install(
);

let src = binary_folder.join(&filename);
let mut dst = get_default_bin_dir().join(binary);
let dst = get_default_bin_dir().join(binary);

println!("Setting {} as default", binary);

#[cfg(windows)]
let mut dst = dst.clone();
#[cfg(windows)]
{
if dst.extension() != Some("exe".as_ref()) {
Expand Down
6 changes: 3 additions & 3 deletions src/handlers/show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use crate::{
handlers::installed_binaries_grouped_by_network,
paths::default_file_path,
types::{Binaries, Version},
types::{Binaries, BinaryVersion, Version},
};
use anyhow::Error;
use std::collections::BTreeMap;
Expand All @@ -19,7 +19,7 @@ fn load_default_binaries() -> Result<Binaries, Error> {
}

/// Load installed binaries grouped by network
fn load_installed_binaries() -> Result<Vec<crate::types::BinaryVersion>, Error> {
fn load_installed_binaries() -> Result<Vec<BinaryVersion>, Error> {
let installed_binaries = installed_binaries_grouped_by_network(None)?;
let binaries = installed_binaries
.into_iter()
Expand All @@ -29,7 +29,7 @@ fn load_installed_binaries() -> Result<Vec<crate::types::BinaryVersion>, Error>
}

/// Display a section with title and binaries table
fn display_binaries_section(title: &str, binaries: &Vec<crate::types::BinaryVersion>) {
fn display_binaries_section(title: &str, binaries: &[BinaryVersion]) {
println!("\x1b[1m{}:\x1b[0m", title);
print_table(binaries);
}
Expand Down
4 changes: 2 additions & 2 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use anyhow::{anyhow, Error};
use std::{
collections::BTreeMap,
fmt::{self, Display, Formatter},
path::PathBuf,
path::Path,
str::FromStr,
};

Expand Down Expand Up @@ -102,7 +102,7 @@ pub enum Network {
}

impl InstalledBinaries {
pub fn create_file(path: &PathBuf) -> Result<(), Error> {
pub fn create_file(path: &Path) -> Result<(), Error> {
let binaries = InstalledBinaries { binaries: vec![] };
write_json_file(path, &binaries)
}
Expand Down
Loading