From 47b39f446a7f744c37e52975d3f65345b01fff07 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Mon, 4 May 2026 04:16:01 +0800 Subject: Switch to published crates and update README for v0.1.7 --- examples/example-async/Cargo.lock | 4 + examples/example-basic/Cargo.lock | 4 + examples/example-completion/Cargo.lock | 4 + examples/example-general-renderer/Cargo.lock | 4 + examples/example-picker/Cargo.lock | 4 + mingling/Cargo.lock | 4 + mingling/Cargo.toml | 4 +- mingling/README.md | 209 ++++++++++++++++++++++++++- mling/Cargo.lock | 6 +- mling/Cargo.toml | 2 +- 10 files changed, 235 insertions(+), 10 deletions(-) diff --git a/examples/example-async/Cargo.lock b/examples/example-async/Cargo.lock index 5d1243e..d9549aa 100644 --- a/examples/example-async/Cargo.lock +++ b/examples/example-async/Cargo.lock @@ -70,6 +70,8 @@ dependencies = [ [[package]] name = "mingling_core" version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e12e0ee263a48336b5a16598a89c2220524af7a0267227160ebed1364ff0a741" dependencies = [ "just_fmt", "once_cell", @@ -79,6 +81,8 @@ dependencies = [ [[package]] name = "mingling_macros" version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7af9a980ada645d77113c0d39877d6a3d3861b271ceb8a1b6bb804177697ad8" dependencies = [ "just_fmt", "once_cell", diff --git a/examples/example-basic/Cargo.lock b/examples/example-basic/Cargo.lock index ae57530..3ed4017 100644 --- a/examples/example-basic/Cargo.lock +++ b/examples/example-basic/Cargo.lock @@ -26,6 +26,8 @@ dependencies = [ [[package]] name = "mingling_core" version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e12e0ee263a48336b5a16598a89c2220524af7a0267227160ebed1364ff0a741" dependencies = [ "just_fmt", "once_cell", @@ -35,6 +37,8 @@ dependencies = [ [[package]] name = "mingling_macros" version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7af9a980ada645d77113c0d39877d6a3d3861b271ceb8a1b6bb804177697ad8" dependencies = [ "just_fmt", "once_cell", diff --git a/examples/example-completion/Cargo.lock b/examples/example-completion/Cargo.lock index 7a54cc1..004c859 100644 --- a/examples/example-completion/Cargo.lock +++ b/examples/example-completion/Cargo.lock @@ -36,6 +36,8 @@ dependencies = [ [[package]] name = "mingling_core" version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e12e0ee263a48336b5a16598a89c2220524af7a0267227160ebed1364ff0a741" dependencies = [ "just_fmt", "just_template", @@ -46,6 +48,8 @@ dependencies = [ [[package]] name = "mingling_macros" version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7af9a980ada645d77113c0d39877d6a3d3861b271ceb8a1b6bb804177697ad8" dependencies = [ "just_fmt", "once_cell", diff --git a/examples/example-general-renderer/Cargo.lock b/examples/example-general-renderer/Cargo.lock index 84e1c28..3051a7c 100644 --- a/examples/example-general-renderer/Cargo.lock +++ b/examples/example-general-renderer/Cargo.lock @@ -72,6 +72,8 @@ dependencies = [ [[package]] name = "mingling_core" version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e12e0ee263a48336b5a16598a89c2220524af7a0267227160ebed1364ff0a741" dependencies = [ "just_fmt", "once_cell", @@ -86,6 +88,8 @@ dependencies = [ [[package]] name = "mingling_macros" version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7af9a980ada645d77113c0d39877d6a3d3861b271ceb8a1b6bb804177697ad8" dependencies = [ "just_fmt", "once_cell", diff --git a/examples/example-picker/Cargo.lock b/examples/example-picker/Cargo.lock index f4dc769..b722ed4 100644 --- a/examples/example-picker/Cargo.lock +++ b/examples/example-picker/Cargo.lock @@ -28,6 +28,8 @@ dependencies = [ [[package]] name = "mingling_core" version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e12e0ee263a48336b5a16598a89c2220524af7a0267227160ebed1364ff0a741" dependencies = [ "just_fmt", "once_cell", @@ -37,6 +39,8 @@ dependencies = [ [[package]] name = "mingling_macros" version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7af9a980ada645d77113c0d39877d6a3d3861b271ceb8a1b6bb804177697ad8" dependencies = [ "just_fmt", "once_cell", diff --git a/mingling/Cargo.lock b/mingling/Cargo.lock index 030b206..08911df 100644 --- a/mingling/Cargo.lock +++ b/mingling/Cargo.lock @@ -236,6 +236,8 @@ dependencies = [ [[package]] name = "mingling_core" version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e12e0ee263a48336b5a16598a89c2220524af7a0267227160ebed1364ff0a741" dependencies = [ "env_logger", "just_fmt", @@ -253,6 +255,8 @@ dependencies = [ [[package]] name = "mingling_macros" version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7af9a980ada645d77113c0d39877d6a3d3861b271ceb8a1b6bb804177697ad8" dependencies = [ "just_fmt", "once_cell", diff --git a/mingling/Cargo.toml b/mingling/Cargo.toml index 61a6c2b..61fca91 100644 --- a/mingling/Cargo.toml +++ b/mingling/Cargo.toml @@ -36,7 +36,7 @@ comp = ["mingling_core/comp", "mingling_macros/comp"] parser = ["dep:size"] [dependencies] -mingling_core = { path = "../mingling_core", default-features = false } -mingling_macros = { path = "../mingling_macros", default-features = false } +mingling_core = { version = "0.1.7", default-features = false } +mingling_macros = { version = "0.1.7", default-features = false } serde = { version = "1.0", features = ["derive"], optional = true } size = { version = "0.5", optional = true } diff --git a/mingling/README.md b/mingling/README.md index f246aa5..7040177 100644 --- a/mingling/README.md +++ b/mingling/README.md @@ -1,14 +1,66 @@ -# Mìng Lìng - 命令 +
+
+
+
+
+ A Rust CLI framework for many subcmds & complex workflows, reduces boilerplate via proc macros, focus on biz logic +
+ + > [!WARNING] > > **Note**: Mingling is still under active development, and its API may change. Feel free to try it out and give us feedback! +> **Hint**: This note will be removed in version `0.5.0` + +## 📚 Contents + +- [🚀 Intro](#🚀-intro) +- [⚡ Quick Start](#⚡-quick-start) +- [🧠 Core Concepts](#🧠-core-concepts) +- [🏗️ Project Structure](#🏗️-project-structure) +- [💡 Example Projects](#💡-example-projects) +- [👣 Next Steps](#👣-next-steps) +- [🗺️ Roadmap](#🗺️-roadmap) +- [🚫 Unplanned Features](#🚫-unplanned-features) +- [📄 License](#📄-license) -`Mingling` is a Rust command-line framework. Its name comes from the Chinese Pinyin for "命令", which means "Command". +## 🚀 Intro -## Quick Start +[`Mingling`](https://github.com/CatilGrass/mingling) is a **proc-macro and type system-based** Rust CLI framework, suitable for developing complex command-line programs with numerous subcommands. -The example below shows how to use `Mingling` to create a simple command-line program: +> BTW: Its name comes from the Chinese Pinyin "mìng lìng", meaning "Command". 😄 + + +## ⚡ Quick Start + +> To use a release version of `Mingling`, get the latest version from [`crates.io`](https://crates.io/crates/mingling) +> +> To use the latest version, pull the project from the `main` branch on `github` + +```toml +# From crates.io +mingling = "0.1.7" + +# From GitHub +mingling = { git = "https://github.com/catilgrass/mingling", branch = "main" } +``` + +The example below shows how to use `Mingling` to create a simple CLI program: ```rust use mingling::macros::{dispatcher, gen_program, r_println, renderer}; @@ -54,7 +106,96 @@ Hello, World! Dispatcher not found for command `hallo` ``` -## Core Concepts +Now, let's see the full usage of **Mingling**: The following example shows how to use `Mingling` to create a complete CLI program with `help`, `completion`, `fallback`, and `parser` features: + +```rust +use mingling::{ + ShellContext, Suggest, + macros::{ + chain, completion, dispatcher, gen_program, help, pack, r_println, renderer, suggest, + }, + parser::AsPicker, + setup::BasicProgramSetup, +}; + +fn main() { + // Initialize program + let mut program = ThisProgram::new(); + + // Load plugins + program.with_setup(BasicProgramSetup); + program.with_dispatcher(CompletionDispatcher); + + // Load commands + program.with_dispatcher(GreetCommand); + + // Run program + program.exec(); +} + +// Define dispatcher `greet` +dispatcher!("greet", GreetCommand => GreetEntry); + +// Define intermediate type `StateGreeting` +pack!(StateGreeting = String); + +// Define `greet` command help +#[help] +fn help_greet_command(_prev: GreetEntry) { + r_println!("Usage: greet
+
+
+
+