aboutsummaryrefslogtreecommitdiff
path: root/mingling/src
diff options
context:
space:
mode:
Diffstat (limited to 'mingling/src')
-rw-r--r--mingling/src/docs/gen_program.md2
-rw-r--r--mingling/src/docs/lib.md2
-rw-r--r--mingling/src/features.rs55
-rw-r--r--mingling/src/gen_program.rs42
4 files changed, 97 insertions, 4 deletions
diff --git a/mingling/src/docs/gen_program.md b/mingling/src/docs/gen_program.md
index 91e7b91..16402c0 100644
--- a/mingling/src/docs/gen_program.md
+++ b/mingling/src/docs/gen_program.md
@@ -7,10 +7,12 @@ You can access them like this:
```rust
# pub struct ThisProgram;
# impl ThisProgram { fn new() -> Self { ThisProgram } }
+# fn main() {
// main.rs / lib.rs
// Use them here via crate::*
let mut program = crate::ThisProgram::new();
+# }
// `ThisProgram` is generated here
// |
diff --git a/mingling/src/docs/lib.md b/mingling/src/docs/lib.md
index 4d20a8b..a7a583b 100644
--- a/mingling/src/docs/lib.md
+++ b/mingling/src/docs/lib.md
@@ -10,7 +10,7 @@
## 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.
+[`Mingling`](https://github.com/mingling-rs/mingling) is a **state-driven and data-driven** CLI workflow orchestration framework built in Rust.
## Use
diff --git a/mingling/src/features.rs b/mingling/src/features.rs
index d1fcbd2..2925f03 100644
--- a/mingling/src/features.rs
+++ b/mingling/src/features.rs
@@ -1,3 +1,14 @@
+/// Whether the `advanced` feature is enabled
+/// Current: `disabled`
+#[cfg(not(feature = "advanced"))]
+#[allow(unused)]
+pub const MINGLING_ADVANCED: bool = false;
+
+/// Whether the `advanced` feature is enabled
+/// Current: `enabled`
+#[cfg(feature = "advanced")]
+#[allow(unused)]
+pub const MINGLING_ADVANCED: bool = true;
/// Whether the `all_serde_fmt` feature is enabled
/// Current: `disabled`
#[cfg(not(feature = "all_serde_fmt"))]
@@ -31,6 +42,28 @@ pub const MINGLING_BUILD: bool = false;
#[cfg(feature = "build")]
#[allow(unused)]
pub const MINGLING_BUILD: bool = true;
+/// Whether the `build_advanced` feature is enabled
+/// Current: `disabled`
+#[cfg(not(feature = "build_advanced"))]
+#[allow(unused)]
+pub const MINGLING_BUILD_ADVANCED: bool = false;
+
+/// Whether the `build_advanced` feature is enabled
+/// Current: `enabled`
+#[cfg(feature = "build_advanced")]
+#[allow(unused)]
+pub const MINGLING_BUILD_ADVANCED: bool = true;
+/// Whether the `build_full` feature is enabled
+/// Current: `disabled`
+#[cfg(not(feature = "build_full"))]
+#[allow(unused)]
+pub const MINGLING_BUILD_FULL: bool = false;
+
+/// Whether the `build_full` feature is enabled
+/// Current: `enabled`
+#[cfg(feature = "build_full")]
+#[allow(unused)]
+pub const MINGLING_BUILD_FULL: bool = true;
/// Whether the `builds` feature is enabled
/// Current: `disabled`
#[cfg(not(feature = "builds"))]
@@ -141,6 +174,17 @@ pub const MINGLING_EXTRAS: bool = false;
#[cfg(feature = "extras")]
#[allow(unused)]
pub const MINGLING_EXTRAS: bool = true;
+/// Whether the `full` feature is enabled
+/// Current: `disabled`
+#[cfg(not(feature = "full"))]
+#[allow(unused)]
+pub const MINGLING_FULL: bool = false;
+
+/// Whether the `full` feature is enabled
+/// Current: `enabled`
+#[cfg(feature = "full")]
+#[allow(unused)]
+pub const MINGLING_FULL: bool = true;
/// Whether the `json_serde_fmt` feature is enabled
/// Current: `disabled`
#[cfg(not(feature = "json_serde_fmt"))]
@@ -163,6 +207,17 @@ pub const MINGLING_MACROS: bool = false;
#[cfg(feature = "macros")]
#[allow(unused)]
pub const MINGLING_MACROS: bool = true;
+/// Whether the `mini` feature is enabled
+/// Current: `disabled`
+#[cfg(not(feature = "mini"))]
+#[allow(unused)]
+pub const MINGLING_MINI: bool = false;
+
+/// Whether the `mini` feature is enabled
+/// Current: `enabled`
+#[cfg(feature = "mini")]
+#[allow(unused)]
+pub const MINGLING_MINI: bool = true;
/// Whether the `nightly` feature is enabled
/// Current: `disabled`
#[cfg(not(feature = "nightly"))]
diff --git a/mingling/src/gen_program.rs b/mingling/src/gen_program.rs
index 144e081..aa0c4b5 100644
--- a/mingling/src/gen_program.rs
+++ b/mingling/src/gen_program.rs
@@ -4,15 +4,27 @@ use mingling_core::ChainProcess;
use mingling_core::Dispatcher;
use mingling_core::Grouped;
use mingling_core::Node;
+use mingling_core::Program;
use mingling_core::ProgramCollect;
/// The next processing step for the current chain.
pub type Next = ChainProcess<ThisProgram>;
+/// The generic program entry point.
+///
+/// This type is created by the `pack!` macro as a variant of the
+/// program's output type set (`ThisProgram`).
+pub struct Entry {
+ /// The arguments provided by the user
+ pub(crate) inner: Vec<String>,
+}
+
/// An enum used to record the set of program type IDs.
///
/// It contains the IDs of all types for this program, registered by the `register_type!` macro.
pub enum ThisProgram {
+ /// The generic program entry point.
+ Entry,
/// Indicates that no matching renderer was found for the given output.
ErrorRendererNotFound,
/// Indicates that no matching dispatcher was found for the given arguments.
@@ -33,7 +45,7 @@ pub enum ThisProgram {
/// program's output type set (`ThisProgram`).
pub struct ErrorRendererNotFound {
/// The name of the renderer that was not found
- inner: String,
+ pub(crate) inner: String,
}
/// A struct representing a "dispatcher not found" error.
@@ -42,7 +54,7 @@ pub struct ErrorRendererNotFound {
/// program's output type set (`ThisProgram`).
pub struct ErrorDispatcherNotFound {
/// The arguments provided by the user
- inner: Vec<String>,
+ pub(crate) inner: Vec<String>,
}
/// A struct representing an empty result.
@@ -64,7 +76,7 @@ pub struct CMDCompletion;
#[cfg(feature = "comp")]
pub struct CompletionContext {
/// The arguments provided by the user
- inner: Vec<String>,
+ pub(crate) inner: Vec<String>,
}
/// Represents a completion suggestion result.
@@ -103,6 +115,18 @@ impl Dispatcher<ThisProgram> for CMDCompletion {
// However, these are marked `unsafe` because the `Grouped` trait requires the
// implementor to guarantee that the type is the only one associated with the
// given enum variant — a guarantee that should be carefully verified in production code.
+unsafe impl Grouped<ThisProgram> for Entry {
+ fn member_id() -> ThisProgram {
+ ThisProgram::Entry
+ }
+}
+
+// SAFETY: These implementations are provided for demonstration purposes only.
+// The `member_id()` implementations map each type to its corresponding variant
+// in the `ThisProgram` enum, and the IDs correctly correspond to the actual types.
+// However, these are marked `unsafe` because the `Grouped` trait requires the
+// implementor to guarantee that the type is the only one associated with the
+// given enum variant — a guarantee that should be carefully verified in production code.
unsafe impl Grouped<ThisProgram> for ErrorRendererNotFound {
fn member_id() -> ThisProgram {
ThisProgram::ErrorRendererNotFound
@@ -229,3 +253,15 @@ impl ProgramCollect for ThisProgram {
todo!()
}
}
+
+impl ThisProgram {
+ /// Create a program through this ProgramCollect.
+ pub fn new() -> Program<ThisProgram> {
+ todo!()
+ }
+
+ /// Get the global singleton of the current program.
+ pub fn this() -> &'static Program<ThisProgram> {
+ todo!()
+ }
+}