From 0a12375f641d878757346cb9fe7b83c5629f018d Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Sat, 2 Nov 2024 00:29:12 +1100 Subject: [PATCH] Improve UI orompt for installation Fixed #1943 The UI now looks like ``` WARN The package cargo-binstall v1.10.9 (aarch64-apple-darwin) has been downloaded from github.com INFO This will install the following binaries: INFO - cargo-binstall => /tmp/e/bin/cargo-binstall ```` Signed-off-by: Jiahao XU --- crates/binstalk-bins/src/lib.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/binstalk-bins/src/lib.rs b/crates/binstalk-bins/src/lib.rs index 2b99ad64..15f92a25 100644 --- a/crates/binstalk-bins/src/lib.rs +++ b/crates/binstalk-bins/src/lib.rs @@ -180,9 +180,19 @@ impl BinFile { } pub fn preview_bin(&self) -> impl fmt::Display + '_ { - LazyFormat { + struct PreviewBin<'a> { + base_name: &'a str, + dest: path::Display<'a>, + } + + impl fmt::Display for PreviewBin<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{} => {}", self.base_name, self.dest) + } + } + + PreviewBin { base_name: &self.base_name, - source: Path::new(self.source.file_name().unwrap()).display(), dest: self.dest.display(), } }