diff options
| author | Weicao-CatilGrass <1992414357@qq.com> | 2026-05-24 03:13:00 +0800 |
|---|---|---|
| committer | Weicao-CatilGrass <1992414357@qq.com> | 2026-05-24 03:13:00 +0800 |
| commit | 289aa96f02f99bb724013e473725760a86ba6190 (patch) | |
| tree | caa818e0fbb66a778b5ad4af61588dfd8b9a3f0f /src/main.rs | |
Initialize Rust project with Cargo and implement memory management CLI
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..480bc49 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,41 @@ +use std::path::PathBuf; + +use mingling::{prelude::*, setup::BasicProgramSetup}; + +mod mem_mgr; +pub use mem_mgr::*; + +#[derive(Debug, Default, Clone)] +pub struct Constants { + pub store_root: PathBuf, +} + +fn main() { + let mut program = ThisProgram::new(); + + // Setup + program.with_setup(BasicProgramSetup); + + // Json + if program.pick_global_flag("--pretty") { + program.general_renderer_name = mingling::GeneralRendererSetting::JsonPretty; + } else { + program.general_renderer_name = mingling::GeneralRendererSetting::Json; + } + + // Resource + let store_root = dirs::data_dir().unwrap().join("memm/"); + std::fs::create_dir_all(&store_root).unwrap(); + program.with_resource(Constants { store_root }); + + program.exec_and_exit(); +} + +dispatcher!("prompt", CMDPromptDisplay => EntryPromptDisplay); + +#[chain] +pub fn render_prompt(_prev: EntryPromptDisplay) { + println!("{}", include_str!("../builtin/PROMPT.md")) +} + +gen_program!(); |
