aboutsummaryrefslogtreecommitdiff
path: root/mingling/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'mingling/src/lib.rs')
-rw-r--r--mingling/src/lib.rs101
1 files changed, 18 insertions, 83 deletions
diff --git a/mingling/src/lib.rs b/mingling/src/lib.rs
index ba87f85..f4bc9dc 100644
--- a/mingling/src/lib.rs
+++ b/mingling/src/lib.rs
@@ -1,73 +1,4 @@
-//! Mingling
-//!
-//! # 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
-//! }
-//!
-//! #[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](_mingling_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)
+#![doc = include_str!("lib.md")]
#[cfg(feature = "core")]
mod example_docs;
@@ -85,12 +16,13 @@ pub mod parser;
/// `Mingling` argument parser (Picker2)
#[cfg(feature = "picker")]
-pub mod picker {
- pub use mingling_picker::*;
+pub mod picker;
- pub mod parselib {
- pub use mingling_picker::parselib::*;
- }
+mod constants;
+
+/// Constants used throughout the Mingling framework.
+pub mod consts {
+ pub use crate::constants::*;
}
/// Re-export of all macros from `mingling_macros`.
@@ -107,6 +39,9 @@ pub mod picker {
#[allow(unused_imports)]
#[cfg(feature = "macros")]
pub mod macros {
+ /// New Parser provided by the `picker` feature
+ #[cfg(feature = "picker")]
+ pub use arg_picker::macros::*;
/// `#[chain]` - Used to generate a struct implementing the `Chain` trait via a method
pub use mingling_macros::chain;
/// `#[completion(EntryType)]` - Used to generate completion entry
@@ -177,18 +112,15 @@ pub mod macros {
/// `suggest_enum!(EnumNames)` - Used to generate enum suggestions
#[cfg(feature = "comp")]
pub use mingling_macros::suggest_enum;
- /// New Parser provided by the `picker` feature
- #[cfg(feature = "picker")]
- pub use mingling_picker::macros::*;
}
/// derive macro `EnumTag`
#[cfg(feature = "macros")]
pub use mingling_macros::EnumTag;
-/// derive macro Groupped
+/// derive macro Grouped
#[cfg(feature = "macros")]
-pub use mingling_macros::Groupped;
+pub use mingling_macros::Grouped;
/// derive macro `StructuralData` — marks a type as supporting structured output
#[cfg(feature = "structural_renderer")]
@@ -239,9 +171,9 @@ pub mod res;
/// use mingling::prelude::*;
/// ```
pub mod prelude {
- /// Re-export of the `Groupped` derive macro for grouping types.
+ /// Re-export of the `Grouped` derive macro for grouping types.
#[cfg(feature = "core")]
- pub use crate::Groupped;
+ pub use crate::Grouped;
/// Re-export of the `RenderResult` struct for outputting rendering result
#[cfg(feature = "core")]
pub use crate::RenderResult;
@@ -286,7 +218,10 @@ pub mod prelude {
pub use crate::parser::AsPicker;
#[cfg(feature = "picker")]
- pub use mingling_picker::prelude::*;
+ pub use arg_picker::prelude::arg;
+
+ #[cfg(feature = "picker")]
+ pub use crate::picker::EntryPicker;
/// Used to enable the `writeln!` macro for `RenderResult`
#[cfg(feature = "core")]