aboutsummaryrefslogtreecommitdiff
path: root/mingling
diff options
context:
space:
mode:
Diffstat (limited to 'mingling')
-rw-r--r--mingling/src/example_docs.rs234
1 files changed, 117 insertions, 117 deletions
diff --git a/mingling/src/example_docs.rs b/mingling/src/example_docs.rs
index ec8162e..2e3f689 100644
--- a/mingling/src/example_docs.rs
+++ b/mingling/src/example_docs.rs
@@ -1,11 +1,11 @@
// Auto generated
/// `Mingling` Example - Basic
-///
-/// # How to Run
-/// ```bash
-/// cargo run --manifest-path ./examples/example-basic/Cargo.toml -- hello World
-/// ```
+///
+/// # How to Run
+/// ```bash
+/// cargo run --manifest-path ./examples/example-basic/Cargo.toml -- hello World
+/// ```
///
/// Cargo.toml
/// ```
@@ -13,7 +13,7 @@
/// name = "example-basic"
/// version = "0.0.1"
/// edition = "2024"
-///
+///
/// [dependencies]
/// mingling = { path = "../../mingling" }
/// tokio = { version = "1", features = ["rt", "rt-multi-thread", "macros"] }
@@ -25,73 +25,73 @@
/// macros::{chain, dispatcher, gen_program, pack, r_println, renderer},
/// marker::NextProcess,
/// };
-///
+///
/// // Define dispatcher `HelloCommand`, directing subcommand "hello" to `HelloEntry`
/// dispatcher!("hello", HelloCommand => HelloEntry);
-///
+///
/// #[tokio::main]
/// async fn main() {
/// // Create program
/// let mut program = ThisProgram::new();
-///
+///
/// // Add dispatcher `HelloCommand`
/// program.with_dispatcher(HelloCommand);
-///
+///
/// // Run program
/// program.exec().await;
/// }
-///
+///
/// // Register wrapper type `Hello`, setting inner to `String`
/// pack!(Hello = String);
-///
+///
/// // Register chain to `ThisProgram`, handling logic from `HelloEntry`
/// #[chain]
/// async fn parse_name(prev: HelloEntry) -> NextProcess {
/// // Extract string from `HelloEntry` as argument
/// let name = prev.first().cloned().unwrap_or_else(|| "World".to_string());
-///
+///
/// // Build `Hello` type and route to renderer
/// Hello::new(name).to_render()
/// }
-///
+///
/// // Register renderer to `ThisProgram`, handling rendering of `Hello`
/// #[renderer]
/// fn render_hello_who(prev: Hello) {
/// // Print message
/// r_println!("Hello, {}!", *prev);
-///
+///
/// // Program ends here
/// }
-///
+///
/// // Generate program, default is `ThisProgram`
/// gen_program!();
/// ```
pub mod example_basic {}
/// `Mingling` Example - Completion
-///
-/// # How to Deploy
-/// 1. Enable the `comp` feature
-/// ```toml
-/// mingling = { version = "0.1.5", features = [
-/// "comp", // Enable this feature
-/// "parser"
-/// ] }
-/// ```
-///
-/// 2. Write `build.rs` to generate completion scripts at compile time
-/// ```rust
-/// use mingling::build::{build_comp_scripts, build_comp_scripts_with_bin_name};
-/// fn main() {
-/// // Generate completion scripts for the current program
-/// build_comp_scripts().unwrap();
-///
-/// // Or specify a specific name
-/// // build_comp_scripts_with_bin_name("your_bin").unwrap();
-/// }
-/// ```
-///
-/// 3. Write `main.rs`, adding completion logic for your command entry point
-/// 4. Execute `cargo install --path ./`, then run the corresponding completion script in your shell
+///
+/// # How to Deploy
+/// 1. Enable the `comp` feature
+/// ```toml
+/// mingling = { version = "0.1.5", features = [
+/// "comp", // Enable this feature
+/// "parser"
+/// ] }
+/// ```
+///
+/// 2. Write `build.rs` to generate completion scripts at compile time
+/// ```rust
+/// use mingling::build::{build_comp_scripts, build_comp_scripts_with_bin_name};
+/// fn main() {
+/// // Generate completion scripts for the current program
+/// build_comp_scripts().unwrap();
+///
+/// // Or specify a specific name
+/// // build_comp_scripts_with_bin_name("your_bin").unwrap();
+/// }
+/// ```
+///
+/// 3. Write `main.rs`, adding completion logic for your command entry point
+/// 4. Execute `cargo install --path ./`, then run the corresponding completion script in your shell
///
/// Cargo.toml
/// ```
@@ -99,7 +99,7 @@ pub mod example_basic {}
/// name = "example-completion"
/// version = "0.0.1"
/// edition = "2024"
-///
+///
/// [dependencies]
/// mingling = { path = "../../mingling", features = ["comp", "parser"] }
/// tokio = { version = "1", features = ["rt", "rt-multi-thread", "macros"] }
@@ -113,10 +113,10 @@ pub mod example_basic {}
/// marker::NextProcess,
/// parser::{Pickable, Picker},
/// };
-///
+///
/// // Define dispatcher `FruitCommand`, directing subcommand "fruit" to `FruitEntry`
/// dispatcher!("fruit", FruitCommand => FruitEntry);
-///
+///
/// #[completion(FruitEntry)]
/// fn comp_fruit_command(ctx: &ShellContext) -> Suggest {
/// if ctx.current_word.starts_with("-") {
@@ -135,7 +135,7 @@ pub mod example_basic {}
/// }
/// return suggest!();
/// }
-///
+///
/// #[tokio::main]
/// async fn main() {
/// let mut program = ThisProgram::new();
@@ -143,13 +143,13 @@ pub mod example_basic {}
/// program.with_dispatcher(FruitCommand);
/// program.exec().await;
/// }
-///
+///
/// #[derive(Groupped)]
/// struct FruitInfo {
/// name: String,
/// fruit_type: FruitType,
/// }
-///
+///
/// #[derive(Default, Debug)]
/// enum FruitType {
/// #[default]
@@ -157,10 +157,10 @@ pub mod example_basic {}
/// Banana,
/// Other(String),
/// }
-///
+///
/// impl Pickable for FruitType {
/// type Output = FruitType;
-///
+///
/// fn pick(args: &mut mingling::parser::Argument, flag: mingling::Flag) -> Option<Self::Output> {
/// let name = args.pick_argument(flag);
/// match name {
@@ -173,7 +173,7 @@ pub mod example_basic {}
/// }
/// }
/// }
-///
+///
/// #[chain]
/// async fn parse_fruit_info(prev: FruitEntry) -> NextProcess {
/// let picker = Picker::<ThisProgram>::from(prev.inner);
@@ -184,7 +184,7 @@ pub mod example_basic {}
/// };
/// AnyOutput::new(info).route_renderer()
/// }
-///
+///
/// #[renderer]
/// fn render_fruit(prev: FruitInfo) {
/// if let FruitType::Other(other) = prev.fruit_type {
@@ -193,43 +193,43 @@ pub mod example_basic {}
/// r_println!("Fruit name: {}, Type: {:?}", prev.name, prev.fruit_type);
/// }
/// }
-///
+///
/// gen_program!();
/// ```
pub mod example_completion {}
/// `Mingling` Example - General Renderer
-///
-/// ## Step1 - Enable Feature
-/// Enable the `general_renderer` feature for mingling in `Cargo.toml`
-/// ```toml
-/// [dependencies]
-/// mingling = { version = "...", features = ["general_renderer", "parser"] }
-/// ```
-///
-/// ## Step2 - Add Dependencies
-/// Add `serde` dependency to `Cargo.toml` for serialization support
-/// ```toml
-/// [dependencies]
-/// serde = { version = "1", features = ["derive"] }
-/// ```
-///
-/// ## Step3 - Write Code
-/// Write the following content into `main.rs`
-///
-/// ## Step3 - Build and Run
-/// ```bash
-/// cargo run --manifest-path ./examples/example-general-renderer/Cargo.toml -- render Bob 22
-/// cargo run --manifest-path ./examples/example-general-renderer/Cargo.toml -- render Bob 22 --json
-/// cargo run --manifest-path ./examples/example-general-renderer/Cargo.toml -- render Bob 22 --yaml
-/// ```
-///
-/// Will print:
-/// ```plain
-/// Bob is 22 years old
-/// {"member_name":"Bob","member_age":22}
-/// member_name: Bob
-/// member_age: 22
-/// ```
+///
+/// ## Step1 - Enable Feature
+/// Enable the `general_renderer` feature for mingling in `Cargo.toml`
+/// ```toml
+/// [dependencies]
+/// mingling = { version = "...", features = ["general_renderer", "parser"] }
+/// ```
+///
+/// ## Step2 - Add Dependencies
+/// Add `serde` dependency to `Cargo.toml` for serialization support
+/// ```toml
+/// [dependencies]
+/// serde = { version = "1", features = ["derive"] }
+/// ```
+///
+/// ## Step3 - Write Code
+/// Write the following content into `main.rs`
+///
+/// ## Step3 - Build and Run
+/// ```bash
+/// cargo run --manifest-path ./examples/example-general-renderer/Cargo.toml -- render Bob 22
+/// cargo run --manifest-path ./examples/example-general-renderer/Cargo.toml -- render Bob 22 --json
+/// cargo run --manifest-path ./examples/example-general-renderer/Cargo.toml -- render Bob 22 --yaml
+/// ```
+///
+/// Will print:
+/// ```plain
+/// Bob is 22 years old
+/// {"member_name":"Bob","member_age":22}
+/// member_name: Bob
+/// member_age: 22
+/// ```
///
/// Cargo.toml
/// ```
@@ -237,7 +237,7 @@ pub mod example_completion {}
/// name = "example-general-renderer"
/// version = "0.0.1"
/// edition = "2024"
-///
+///
/// [dependencies]
/// mingling = { path = "../../mingling", features = [
/// "parser",
@@ -257,9 +257,9 @@ pub mod example_completion {}
/// setup::GeneralRendererSetup,
/// };
/// use serde::Serialize;
-///
+///
/// dispatcher!("render", RenderCommand => RenderCommandEntry);
-///
+///
/// #[tokio::main]
/// async fn main() {
/// let mut program = ThisProgram::new();
@@ -268,7 +268,7 @@ pub mod example_completion {}
/// program.with_dispatcher(RenderCommand);
/// program.exec().await;
/// }
-///
+///
/// // Manually implement Info struct
/// #[derive(Serialize, Groupped)]
/// struct Info {
@@ -277,7 +277,7 @@ pub mod example_completion {}
/// #[serde(rename = "member_age")]
/// age: i32,
/// }
-///
+///
/// #[chain]
/// async fn parse_render(prev: RenderCommandEntry) -> NextProcess {
/// let (name, age) = Picker::<AnyOutput<ThisProgram>>::new(prev.inner)
@@ -286,34 +286,34 @@ pub mod example_completion {}
/// .unpack_directly();
/// AnyOutput::new(Info { name, age }).route_renderer()
/// }
-///
+///
/// // Implement default renderer for when general_renderer is not specified
/// #[renderer]
/// fn render_info(prev: Info) {
/// r_println!("{} is {} years old", prev.name, prev.age);
/// }
-///
+///
/// gen_program!();
/// ```
pub mod example_general_renderer {}
/// `Mingling` Example - Picker
-///
-/// ## Step1 - Enable Feature
-/// Enable the `parser` feature for mingling in `Cargo.toml`
-/// ```toml
-/// [dependencies]
-/// mingling = { version = "...", features = ["parser"] }
-/// ```
-///
-/// ## Step2 - Write Code
-/// Write the following content into `main.rs`
-///
-/// ## Step3 - Build and Run
-/// ```bash
-/// cargo run --manifest-path ./examples/example-picker/Cargo.toml -- pick Bob
-/// cargo run --manifest-path ./examples/example-picker/Cargo.toml -- pick Bob --age -15
-/// cargo run --manifest-path ./examples/example-picker/Cargo.toml -- pick --age 99
-/// ```
+///
+/// ## Step1 - Enable Feature
+/// Enable the `parser` feature for mingling in `Cargo.toml`
+/// ```toml
+/// [dependencies]
+/// mingling = { version = "...", features = ["parser"] }
+/// ```
+///
+/// ## Step2 - Write Code
+/// Write the following content into `main.rs`
+///
+/// ## Step3 - Build and Run
+/// ```bash
+/// cargo run --manifest-path ./examples/example-picker/Cargo.toml -- pick Bob
+/// cargo run --manifest-path ./examples/example-picker/Cargo.toml -- pick Bob --age -15
+/// cargo run --manifest-path ./examples/example-picker/Cargo.toml -- pick --age 99
+/// ```
///
/// Cargo.toml
/// ```
@@ -321,7 +321,7 @@ pub mod example_general_renderer {}
/// name = "example-picker"
/// version = "0.0.1"
/// edition = "2024"
-///
+///
/// [dependencies]
/// mingling = { path = "../../mingling", features = ["parser"] }
/// tokio = { version = "1", features = ["rt", "rt-multi-thread", "macros"] }
@@ -335,19 +335,19 @@ pub mod example_general_renderer {}
/// marker::NextProcess,
/// parser::Picker,
/// };
-///
+///
/// dispatcher!("pick", PickCommand => PickEntry);
-///
+///
/// #[tokio::main]
/// async fn main() {
/// let mut program = ThisProgram::new();
/// program.with_dispatcher(PickCommand);
/// program.exec().await;
/// }
-///
+///
/// pack!(NoNameProvided = ());
/// pack!(ParsedPickInput = (i32, String));
-///
+///
/// #[chain]
/// async fn parse(prev: PickEntry) -> NextProcess {
/// // Extract arguments from `PickEntry`'s inner and create a `Picker`
@@ -359,24 +359,24 @@ pub mod example_general_renderer {}
/// // Then sequentially extract the remaining arguments
/// .pick_or_route((), AnyOutput::new(NoNameProvided::default()))
/// .unpack();
-///
+///
/// match picked {
/// Ok(value) => ParsedPickInput::new(value).to_render(),
/// Err(e) => e.route_renderer(),
/// }
/// }
-///
+///
/// #[renderer]
/// fn render_parsed_pick_input(prev: ParsedPickInput) {
/// let (age, name) = prev.inner;
/// r_println!("Picked: name = {}, age = {}", name, age);
/// }
-///
+///
/// #[renderer]
/// fn render_no_name_input(_prev: NoNameProvided) {
/// r_println!("No name provided.");
/// }
-///
+///
/// gen_program!();
/// ```
-pub mod example_picker {} \ No newline at end of file
+pub mod example_picker {}