diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-08-17 05:49:19 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-08-17 05:49:19 +0800 |
| commit | 57c53affe3542cb6bd4e79ee4c18f20a1bd76b2d (patch) | |
| tree | 1cd4aef44cb7a45a8cd9d520b598f5f181e24c76 /mingling_cli/src/pkg_mgr/cmd_internal_loadpkgs.rs | |
| parent | ef23cd944402939605c78a4a853ef6e33af02c21 (diff) | |
refactor!: replace pack! macros with derive-based pipeline types
Remove the `pack!`, `pack_err!`, `pack_structural!`, and
`pack_err_structural!` macros, replacing all pipeline type definitions
with `#[derive(Grouped)]` and `#[derive(Grouped, Wrap)]` attributes.
This changes the generated struct shape from named-field structs with an
`inner` field to tuple structs accessed via `.0`, and removes the
auto-generated `name` and `info` fields from error types.
Diffstat (limited to 'mingling_cli/src/pkg_mgr/cmd_internal_loadpkgs.rs')
| -rw-r--r-- | mingling_cli/src/pkg_mgr/cmd_internal_loadpkgs.rs | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/mingling_cli/src/pkg_mgr/cmd_internal_loadpkgs.rs b/mingling_cli/src/pkg_mgr/cmd_internal_loadpkgs.rs index b4928ce..f0ac88a 100644 --- a/mingling_cli/src/pkg_mgr/cmd_internal_loadpkgs.rs +++ b/mingling_cli/src/pkg_mgr/cmd_internal_loadpkgs.rs @@ -4,8 +4,8 @@ use std::{ }; use mingling::{ - Routable, - macros::{buffer, command, pack, r_println, renderer, routeify}, + Grouped, Routable, Wrap, + macros::{buffer, command, r_println, renderer, routeify}, }; use crate::{ @@ -14,16 +14,18 @@ use crate::{ }; // Version directory paths of every enabled package. -pack!(ResultLoadPkgsPaths = Vec<PathBuf>); +#[derive(Grouped, Wrap)] +pub struct ResultLoadPkgsPaths(Vec<PathBuf>); // Completion script paths of every enabled package. -pack!(ResultLoadPkgsComps = Vec<PathBuf>); +#[derive(Grouped, Wrap)] +pub struct ResultLoadPkgsComps(Vec<PathBuf>); #[command(node = "__loadpkgs_path", routeify)] pub fn load_packages_paths(packages_dir: &ResPackagesDir) -> Next { let packages_dir = &packages_dir.path; if packages_dir.as_os_str().is_empty() { - return ErrorNoDataDirectory::default().to_chain(); + return ErrorNoDataDirectory.to_chain(); } let paths = enabled_version_dirs(packages_dir).map_err(|e| { io::Error::new( @@ -31,14 +33,14 @@ pub fn load_packages_paths(packages_dir: &ResPackagesDir) -> Next { format!("failed to read {}: {e}", packages_dir.display()), ) })?; - ResultLoadPkgsPaths::new(paths).to_chain() + ResultLoadPkgsPaths(paths).to_chain() } #[command(node = "__loadpkgs_comp_scripts", routeify)] pub fn load_packages_comp_scripts(packages_dir: &ResPackagesDir) -> Next { let packages_dir = &packages_dir.path; if packages_dir.as_os_str().is_empty() { - return ErrorNoDataDirectory::default().to_chain(); + return ErrorNoDataDirectory.to_chain(); } let scripts = comp_scripts(packages_dir).map_err(|e| { io::Error::new( @@ -46,19 +48,19 @@ pub fn load_packages_comp_scripts(packages_dir: &ResPackagesDir) -> Next { format!("failed to read {}: {e}", packages_dir.display()), ) })?; - ResultLoadPkgsComps::new(scripts).to_chain() + ResultLoadPkgsComps(scripts).to_chain() } #[renderer(buffer)] pub fn render_result_load_pkgs_paths(r: ResultLoadPkgsPaths) { - for path in r.inner { + for path in r.0 { r_println!("{}", path.display()); } } #[renderer(buffer)] pub fn render_result_load_pkgs_comps(r: ResultLoadPkgsComps) { - for path in r.inner { + for path in r.0 { r_println!("{}", path.display()); } } |
