Skip to content

Commit

Permalink
fixed grammar and replaced .unwrap() with .expect() instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
u-train committed Nov 1, 2024
1 parent 756c58f commit 2ccf705
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
14 changes: 9 additions & 5 deletions src/commands/install.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use std::collections::BTreeSet;


use std::io::Write;
use std::path::PathBuf;
use std::time::Duration;

use crossterm::style::{Attribute, Color, SetAttribute, SetForegroundColor};
use indicatif::{ProgressBar, ProgressStyle};

use std::io::Write;
use structopt::StructOpt;

use crate::installation::InstallationContext;
Expand All @@ -16,7 +17,7 @@ use crate::package_id::PackageId;
use crate::package_source::{PackageSource, PackageSourceMap, Registry, TestRegistry};
use crate::resolution::resolve;

use super::utils::{generate_depedency_changes, render_update_difference};
use super::utils::{generate_dependency_changes, render_update_difference};
use super::GlobalOptions;

/// Install all of the dependencies of this project.
Expand Down Expand Up @@ -73,7 +74,8 @@ impl InstallSubcommand {

let old_dependencies = &try_to_use;

let changes = generate_depedency_changes(old_dependencies, &latest_graph.activated);
let changes =
generate_dependency_changes(old_dependencies, &latest_graph.activated);
let mut error_output = Vec::new();

writeln!(
Expand All @@ -82,7 +84,9 @@ impl InstallSubcommand {
SetForegroundColor(Color::Yellow),
SetForegroundColor(Color::Reset)
)?;

render_update_difference(&changes, &mut error_output)?;

writeln!(
error_output,
"{}{} Suggestion{}{} try running wally update",
Expand All @@ -92,8 +96,8 @@ impl InstallSubcommand {
SetAttribute(Attribute::Reset)
)?;

// Should be safe since we're only getting valid utf-8.
anyhow::bail!(String::from_utf8(error_output).unwrap());
anyhow::bail!(String::from_utf8(error_output)
.expect("output from render_update_difference should always be utf-8"));
}

progress.println(format!(
Expand Down
9 changes: 6 additions & 3 deletions src/commands/update.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::collections::BTreeSet;

use std::path::PathBuf;
use std::str::FromStr;
use std::time::Duration;
Expand All @@ -15,7 +16,7 @@ use crossterm::style::{Attribute, Color, SetAttribute, SetForegroundColor};
use indicatif::{ProgressBar, ProgressStyle};
use structopt::StructOpt;

use super::utils::{generate_depedency_changes, render_update_difference};
use super::utils::{generate_dependency_changes, render_update_difference};

/// Update all of the dependencies of this project.
#[derive(Debug, StructOpt)]
Expand Down Expand Up @@ -99,8 +100,10 @@ impl UpdateSubcommand {

progress.enable_steady_tick(Duration::from_millis(100));
progress.suspend(|| {
let dependency_changes =
generate_depedency_changes(&lockfile.as_ids().collect(), &resolved_graph.activated);
let dependency_changes = generate_dependency_changes(
&lockfile.as_ids().collect(),
&resolved_graph.activated,
);
render_update_difference(&dependency_changes, &mut std::io::stdout()).unwrap();
});

Expand Down
2 changes: 1 addition & 1 deletion src/commands/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub(crate) enum DependencyChange {
Downgrade { from: PackageId, to: PackageId },
}

pub(crate) fn generate_depedency_changes(
pub(crate) fn generate_dependency_changes(
old_dependencies: &BTreeSet<PackageId>,
new_dependencies: &BTreeSet<PackageId>,
) -> Vec<DependencyChange> {
Expand Down

0 comments on commit 2ccf705

Please sign in to comment.