blob: 7aea59d862c1f757fda1e487e75a4c1ff84f4d5e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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");
}
|