aboutsummaryrefslogtreecommitdiff
path: root/mling/src/cli/install.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-04-28 16:27:10 +0800
committer魏曹先生 <1992414357@qq.com>2026-04-28 16:27:10 +0800
commit6a907b71f945bf49d27a001f279bf116ad7297d8 (patch)
tree021a01d1d4c1cf1439ed19aca65e45b247fba9d1 /mling/src/cli/install.rs
parent881e7399b2417c32fa996d94c6b389c1e06d8eb1 (diff)
Rename refresh command to install
Diffstat (limited to 'mling/src/cli/install.rs')
-rw-r--r--mling/src/cli/install.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/mling/src/cli/install.rs b/mling/src/cli/install.rs
new file mode 100644
index 0000000..dc2cf57
--- /dev/null
+++ b/mling/src/cli/install.rs
@@ -0,0 +1,32 @@
+use mingling::{
+ ShellContext, Suggest,
+ macros::{chain, completion, dispatcher, pack, suggest},
+ parser::Picker,
+};
+
+use crate::{ThisProgram, project_installer::install_all};
+
+dispatcher!("install", InstallCommand => InstallEntry);
+
+pack!(ResultInstallCompleted = ());
+
+#[completion(InstallEntry)]
+pub(crate) fn comp_install(ctx: &ShellContext) -> Suggest {
+ if ctx.typing_argument() {
+ return suggest! {
+ "--clean": "Clean build artifacts before installation",
+ "-c": "Clean build artifacts before installation",
+ };
+ }
+ return suggest!();
+}
+
+#[chain]
+pub(crate) fn handle_install_entry(prev: InstallEntry) -> NextProcess {
+ let is_clean_before_build = Picker::new(prev.inner)
+ .pick::<bool>(["--clean", "-c"])
+ .unpack();
+ let _ = install_all(is_clean_before_build);
+
+ ResultInstallCompleted::new(())
+}