aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md9
-rw-r--r--mingling/src/features.rs53
-rw-r--r--mingling/src/lib.rs30
3 files changed, 92 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 583766d..51ca3c2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -37,6 +37,15 @@ fn proc(prev: HelloEntry) -> ChainProcess<ThisProgram> {
3. **\[mingling\]** Added the `dispatch_tree` feature. When enabled, it will automatically generate a prefix tree, improving the command lookup efficiency from O(n) to O(len)
+4. **\[mingling\]** Added `mingling::feature` module for runtime feature detection. You can now check which features are enabled at compile time:
+
+```rust
+// Example: Check if a feature is enabled
+if mingling::feature::MINGLING_ASYNC {
+ // async feature is enabled
+}
+```
+
#### **BREAKING CHANGES**:
None
diff --git a/mingling/src/features.rs b/mingling/src/features.rs
new file mode 100644
index 0000000..d75f926
--- /dev/null
+++ b/mingling/src/features.rs
@@ -0,0 +1,53 @@
+#[cfg(not(feature = "nightly"))]
+pub const MINGLING_NIGHTLY: bool = false;
+
+#[cfg(feature = "nightly")]
+pub const MINGLING_NIGHTLY: bool = true;
+
+#[cfg(not(feature = "debug"))]
+pub const MINGLING_DEBUG: bool = false;
+
+#[cfg(feature = "debug")]
+pub const MINGLING_DEBUG: bool = true;
+
+#[cfg(not(feature = "async"))]
+pub const MINGLING_ASYNC: bool = false;
+
+#[cfg(feature = "async")]
+pub const MINGLING_ASYNC: bool = true;
+
+#[cfg(not(feature = "clap"))]
+pub const MINGLING_CLAP: bool = false;
+
+#[cfg(feature = "clap")]
+pub const MINGLING_CLAP: bool = true;
+
+#[cfg(not(feature = "dispatch_tree"))]
+pub const MINGLING_DISPATCH_TREE: bool = false;
+
+#[cfg(feature = "dispatch_tree")]
+pub const MINGLING_DISPATCH_TREE: bool = true;
+
+#[cfg(not(feature = "general_renderer"))]
+pub const MINGLING_GENERAL_RENDERER: bool = false;
+
+#[cfg(feature = "general_renderer")]
+pub const MINGLING_GENERAL_RENDERER: bool = true;
+
+#[cfg(not(feature = "repl"))]
+pub const MINGLING_REPL: bool = false;
+
+#[cfg(feature = "repl")]
+pub const MINGLING_REPL: bool = true;
+
+#[cfg(not(feature = "comp"))]
+pub const MINGLING_COMP: bool = false;
+
+#[cfg(feature = "comp")]
+pub const MINGLING_COMP: bool = true;
+
+#[cfg(not(feature = "parser"))]
+pub const MINGLING_PARSER: bool = false;
+
+#[cfg(feature = "parser")]
+pub const MINGLING_PARSER: bool = true;
diff --git a/mingling/src/lib.rs b/mingling/src/lib.rs
index f366296..21a848d 100644
--- a/mingling/src/lib.rs
+++ b/mingling/src/lib.rs
@@ -137,3 +137,33 @@ pub use mingling_macros::Groupped;
pub mod _mingling_examples {
pub use crate::example_docs::*;
}
+
+mod features;
+pub mod feature {
+ /// Whether the `async` feature is enabled
+ pub use crate::features::MINGLING_ASYNC;
+
+ /// Whether the `clap` feature is enabled
+ pub use crate::features::MINGLING_CLAP;
+
+ /// Whether the `comp` feature is enabled
+ pub use crate::features::MINGLING_COMP;
+
+ /// Whether the `debug` feature is enabled
+ pub use crate::features::MINGLING_DEBUG;
+
+ /// Whether the `dispatch_tree` feature is enabled
+ pub use crate::features::MINGLING_DISPATCH_TREE;
+
+ /// Whether the `general_renderer` feature is enabled
+ pub use crate::features::MINGLING_GENERAL_RENDERER;
+
+ /// Whether the `nightly` feature is enabled
+ pub use crate::features::MINGLING_NIGHTLY;
+
+ /// Whether the `parser` feature is enabled
+ pub use crate::features::MINGLING_PARSER;
+
+ /// Whether the `repl` feature is enabled
+ pub use crate::features::MINGLING_REPL;
+}