Improve UI orompt for installation (#1950)

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 <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2024-11-02 10:52:37 +10:00 committed by GitHub
parent 48f8cf9b86
commit a944df0498
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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(),
}
}