From 3424b9783e77743ebe3d9d77ce25df4485ac31d0 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sat, 1 Aug 2026 22:00:22 +0800 Subject: chore: move lib.md to docs directory --- mingling/src/docs/lib.md | 96 ++++++++++++++++++++++++++++++++++++++++++++++++ mingling/src/lib.md | 96 ------------------------------------------------ mingling/src/lib.rs | 2 +- 3 files changed, 97 insertions(+), 97 deletions(-) create mode 100644 mingling/src/docs/lib.md delete mode 100644 mingling/src/lib.md diff --git a/mingling/src/docs/lib.md b/mingling/src/docs/lib.md new file mode 100644 index 0000000..4d20a8b --- /dev/null +++ b/mingling/src/docs/lib.md @@ -0,0 +1,96 @@ +
+ /mɪŋ lɪŋ/ +
+ ++ Macro magician in your CLI. +
+ +## Intro + +[`Mingling`](https://github.com/mingling-rs/mingling) is a **proc-macro and type system-based** Rust CLI framework, suitable for developing complex command-line programs with numerous subcommands. + +## Use + +Here is a basic project written using **Mingling**: + +- When the user types `greet`, the program outputs `Hello, World!` +- When the user types `greet Alice`, the program outputs `Hello, Alice!` + +```rust +use mingling::prelude::*; + +dispatcher!("greet", CMDGreet => EntryGreet); + +fn main() { + let mut program = ThisProgram::new(); + program.with_dispatcher(CMDGreet); + program.exec_and_exit(); +} + +pack!(ResultName = String); + +#[chain] +fn handle_greet(args: EntryGreet) -> Next { + let name: ResultName = args + .inner + .first() + .cloned() + .unwrap_or_else(|| "World".to_string()) + .into(); + name.into() +} + +#[renderer] +fn render_name(name: ResultName) -> RenderResult { + let mut result = RenderResult::default(); + result.println(&format!("Hello, {}!", *name)); + result +} + +#[renderer] +fn render_dispatcher_not_found(err: ErrorDispatcherNotFound) -> RenderResult { + let mut result = RenderResult::default(); + if err.len() > 0 { + result.println(&format!("Command not found: [{}]", err.join(" "))); + } + result +} + +gen_program!(); +``` + +Output: + +```text +> mycmd greet +Hello, World! +> mycmd greet Alice +Hello, Alice! +> mycmd great +Command not found: [great] +``` + +## Examples + +`Mingling` provides detailed usage examples for your reference. +See [Examples](EXAMPLES/index.html) or [Helpdoc](https://mingling-rs.github.io/mingling/docs/examples.html) + +## About Features + +All features of `Mingling` are opt-in. To learn what each feature provides, see [Features](feature/index.html) or [Helpdoc](https://mingling-rs.github.io/mingling/docs/doc.html#/pages/other/features) + +## Use unreleased version + +If you want to use the latest development version, you can pull from the [Unreleased](https://github.com/mingling-rs/mingling/tree/unreleased) branch on [GitHub](https://github.com/mingling-rs/mingling) by adding the following to your `Cargo.toml`: + +```toml +[dependencies.mingling] +git = "https://github.com/mingling-rs/mingling.git" +tag = "unreleased" +features = [] +``` + +**Please note** that the documentation for the latest version may differ from this article. It is recommended to refer to the [latest documentation](https://mingling-rs.github.io/mingling/docs/api-docs/mingling/). diff --git a/mingling/src/lib.md b/mingling/src/lib.md deleted file mode 100644 index 4d20a8b..0000000 --- a/mingling/src/lib.md +++ /dev/null @@ -1,96 +0,0 @@ -- /mɪŋ lɪŋ/ -
- -- Macro magician in your CLI. -
- -## Intro - -[`Mingling`](https://github.com/mingling-rs/mingling) is a **proc-macro and type system-based** Rust CLI framework, suitable for developing complex command-line programs with numerous subcommands. - -## Use - -Here is a basic project written using **Mingling**: - -- When the user types `greet`, the program outputs `Hello, World!` -- When the user types `greet Alice`, the program outputs `Hello, Alice!` - -```rust -use mingling::prelude::*; - -dispatcher!("greet", CMDGreet => EntryGreet); - -fn main() { - let mut program = ThisProgram::new(); - program.with_dispatcher(CMDGreet); - program.exec_and_exit(); -} - -pack!(ResultName = String); - -#[chain] -fn handle_greet(args: EntryGreet) -> Next { - let name: ResultName = args - .inner - .first() - .cloned() - .unwrap_or_else(|| "World".to_string()) - .into(); - name.into() -} - -#[renderer] -fn render_name(name: ResultName) -> RenderResult { - let mut result = RenderResult::default(); - result.println(&format!("Hello, {}!", *name)); - result -} - -#[renderer] -fn render_dispatcher_not_found(err: ErrorDispatcherNotFound) -> RenderResult { - let mut result = RenderResult::default(); - if err.len() > 0 { - result.println(&format!("Command not found: [{}]", err.join(" "))); - } - result -} - -gen_program!(); -``` - -Output: - -```text -> mycmd greet -Hello, World! -> mycmd greet Alice -Hello, Alice! -> mycmd great -Command not found: [great] -``` - -## Examples - -`Mingling` provides detailed usage examples for your reference. -See [Examples](EXAMPLES/index.html) or [Helpdoc](https://mingling-rs.github.io/mingling/docs/examples.html) - -## About Features - -All features of `Mingling` are opt-in. To learn what each feature provides, see [Features](feature/index.html) or [Helpdoc](https://mingling-rs.github.io/mingling/docs/doc.html#/pages/other/features) - -## Use unreleased version - -If you want to use the latest development version, you can pull from the [Unreleased](https://github.com/mingling-rs/mingling/tree/unreleased) branch on [GitHub](https://github.com/mingling-rs/mingling) by adding the following to your `Cargo.toml`: - -```toml -[dependencies.mingling] -git = "https://github.com/mingling-rs/mingling.git" -tag = "unreleased" -features = [] -``` - -**Please note** that the documentation for the latest version may differ from this article. It is recommended to refer to the [latest documentation](https://mingling-rs.github.io/mingling/docs/api-docs/mingling/). diff --git a/mingling/src/lib.rs b/mingling/src/lib.rs index 8f2540c..7dbd018 100644 --- a/mingling/src/lib.rs +++ b/mingling/src/lib.rs @@ -3,7 +3,7 @@ html_favicon_url = "https://github.com/mingling-rs/mingling/raw/main/docs/res/favicon_small.png" )] #![deny(missing_docs)] -#![doc = include_str!("lib.md")] +#![doc = include_str!("docs/lib.md")] #![cfg_attr(docsrs, feature(doc_cfg))] #[cfg(feature = "core")] -- cgit