diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-08-07 15:48:37 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-08-07 16:57:24 +0800 |
| commit | 180f72d307d75351bc8baa19b8ac662ef58fc35f (patch) | |
| tree | 95e20641afff1b0ac9c2c45e0cfa03ad1dbf2d63 /mingling_cli/src/pkg_mgr.rs | |
| parent | a4c49f54420b640a1379e2a84042bdc64be2f798 (diff) | |
feat(pkg_mgr): add uninstall command and improve install
Implement `mling uninstall` to remove installed packages by name or
name@version, with shell completion support. Rework install to build
release binaries, copy them plus completion scripts to a per-version
directory under the user data dir.
Diffstat (limited to 'mingling_cli/src/pkg_mgr.rs')
| -rw-r--r-- | mingling_cli/src/pkg_mgr.rs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/mingling_cli/src/pkg_mgr.rs b/mingling_cli/src/pkg_mgr.rs index b77c3b3..7aea59d 100644 --- a/mingling_cli/src/pkg_mgr.rs +++ b/mingling_cli/src/pkg_mgr.rs @@ -1,2 +1,40 @@ pub mod cmd_install; +pub mod cmd_uninstall; +use std::path::PathBuf; + +use mingling::{ + Program, + macros::{buffer, pack_err, program_setup, r_println, renderer}, +}; + +use crate::ThisProgram; + +pack_err!(ErrorRootPackageNotFound); +pack_err!(ErrorNoDataDirectory); + +/// The `.mingling` packages directory under the user's data directory. +#[derive(Debug, Default, Clone)] +pub struct ResPackagesDir { + pub path: PathBuf, +} + +#[program_setup] +pub fn package_manager_setup(program: &mut Program<ThisProgram>) { + let path = dirs::data_dir() + .map(|data_dir| data_dir.join(".mingling")) + .unwrap_or_default(); + program.with_resource(ResPackagesDir { path }); +} + +#[renderer(buffer)] +pub fn render_error_root_package_not_found(_: ErrorRootPackageNotFound) { + r_println!("error: failed to determine the root package"); + r_println!(""); + r_println!("Run `mling install` / `mling uninstall` inside a Cargo workspace"); +} + +#[renderer(buffer)] +pub fn render_error_no_data_directory(_: ErrorNoDataDirectory) { + r_println!("error: failed to determine the data directory"); +} |
