diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-07-11 14:44:17 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-07-11 14:44:17 +0800 |
| commit | c5736152b0adeef17349265c4b9277ba17b8bcfd (patch) | |
| tree | a5a5227ef4ca20ec09d1c8cf0655e9f9f33e03b6 /mling/src/proj_mgr/show_binaries.rs | |
| parent | c08b2d608abe134e37bc4dee7df2113fac968e06 (diff) | |
feat: require renderers to return RenderResult instead of mutating one
BREAKING CHANGE: The `render` method on `Renderer`, `HelpRequest`, and
`ProgramCollect` now returns `RenderResult` instead of taking
`&mut RenderResult`. The `r_print!` and `r_println!` macros have been
removed in favor of using `std::io::Write` directly on `RenderResult`.
Diffstat (limited to 'mling/src/proj_mgr/show_binaries.rs')
| -rw-r--r-- | mling/src/proj_mgr/show_binaries.rs | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/mling/src/proj_mgr/show_binaries.rs b/mling/src/proj_mgr/show_binaries.rs index d6872cf..fd2f406 100644 --- a/mling/src/proj_mgr/show_binaries.rs +++ b/mling/src/proj_mgr/show_binaries.rs @@ -2,18 +2,19 @@ use std::path::PathBuf; use colored::Colorize; use mingling::{ - Groupped, - macros::{chain, pack, r_print, r_println, renderer}, + macros::{chain, pack, renderer}, + Groupped, RenderResult, }; use serde::Serialize; +use std::io::Write as _; use crate::{ - Next, proj_mgr::{ + metadata::{read_metadata, CargoLockFile}, EntryShowBinaries, - metadata::{CargoLockFile, read_metadata}, }, res::ResManifestPath, + Next, }; #[derive(Serialize, Groupped)] @@ -58,16 +59,20 @@ pub fn handle_show_binaries(_args: EntryShowBinaries, manifest_path: &ResManifes } #[renderer] -pub fn render_binaries(binaries: ResultBinaries) -> String { - r_println!("{}", "Binaries:".bright_cyan().bold()); +pub fn render_binaries(binaries: ResultBinaries) -> RenderResult { + let mut result = RenderResult::default(); + writeln!(result, "{}", "Binaries:".bright_cyan().bold()).ok(); if let Some(max_name_len) = binaries.binaries.iter().map(|b| b.name.len()).max() { for binary in &binaries.binaries { - r_println!( + writeln!( + result, " {:width$} `{}`", binary.name.bright_yellow().bold(), binary.path.display().to_string().italic(), width = max_name_len - ); + ) + .ok(); } } + result } |
