aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-07-14 18:48:17 +0800
committer魏曹先生 <1992414357@qq.com>2026-07-14 18:48:17 +0800
commit17e59392be8b08bc6e323551d2e4b12f770bfe88 (patch)
treecbf84db3ccb48ba2c4ba2a0deb583d2ccf30ec8b
parent16bef0a5289586a1999c85a746aaea766f260774 (diff)
feat(mingling): make core and macros features optional
-rw-r--r--.run/src/bin/doc.ps12
-rw-r--r--.run/src/bin/doc.sh2
-rw-r--r--mingling/Cargo.toml11
-rw-r--r--mingling/src/lib.rs35
-rw-r--r--mingling_picker/src/picker/patterns.rs1
5 files changed, 41 insertions, 10 deletions
diff --git a/.run/src/bin/doc.ps1 b/.run/src/bin/doc.ps1
index 2ee3be6..fd7afaa 100644
--- a/.run/src/bin/doc.ps1
+++ b/.run/src/bin/doc.ps1
@@ -1 +1 @@
-cargo doc --workspace --no-deps --features builds,structural_renderer,repl,comp,parser,picker,clap,extra_macros --open
+cargo doc --workspace --no-deps --features core,macros,builds,structural_renderer,repl,comp,parser,picker,clap,extra_macros --open
diff --git a/.run/src/bin/doc.sh b/.run/src/bin/doc.sh
index ea903ca..2d59896 100644
--- a/.run/src/bin/doc.sh
+++ b/.run/src/bin/doc.sh
@@ -1,3 +1,3 @@
#!/bin/bash
-cargo doc --workspace --no-deps --features builds,structural_renderer,repl,comp,parser,picker,clap,extra_macros --open
+cargo doc --workspace --no-deps --features core,macros,builds,structural_renderer,repl,comp,parser,picker,clap,extra_macros --open
diff --git a/mingling/Cargo.toml b/mingling/Cargo.toml
index 1b5b926..2cd517e 100644
--- a/mingling/Cargo.toml
+++ b/mingling/Cargo.toml
@@ -22,6 +22,8 @@ mingling = { path = ".", features = [
[package.metadata.docs.rs]
features = [
+ "core",
+ "macros",
"builds",
"structural_renderer",
"repl",
@@ -33,12 +35,15 @@ features = [
]
[features]
+core = ["dep:mingling_core", "mingling_core/default"]
+macros = ["dep:mingling_macros", "mingling_macros/default"]
+
nightly = ["mingling_core/nightly", "mingling_macros/nightly"]
debug = ["mingling_core/debug"]
async = ["mingling_core/async", "mingling_macros/async"]
builds = ["mingling_core/builds"]
-default = ["mingling_core/default", "mingling_macros/default"]
+default = ["core", "macros"]
clap = ["mingling_core/clap", "mingling_macros/clap"]
dispatch_tree = ["mingling_core/dispatch_tree", "mingling_macros/dispatch_tree"]
@@ -83,8 +88,8 @@ ron_serde_fmt = ["mingling_core/ron_serde_fmt"]
extra_macros = ["mingling_macros/extra_macros"]
[dependencies]
-mingling_core.workspace = true
-mingling_macros.workspace = true
+mingling_core = { workspace = true, optional = true }
+mingling_macros = { workspace = true, optional = true }
mingling_picker = { workspace = true, optional = true }
serde = { workspace = true, optional = true }
size = { version = "0.5", optional = true }
diff --git a/mingling/src/lib.rs b/mingling/src/lib.rs
index 49faceb..ba87f85 100644
--- a/mingling/src/lib.rs
+++ b/mingling/src/lib.rs
@@ -69,10 +69,14 @@
//! # 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)
+#[cfg(feature = "core")]
mod example_docs;
// Re-export Core lib
+#[cfg(feature = "core")]
pub use mingling::*;
+
+#[cfg(feature = "core")]
pub use mingling_core as mingling;
/// `Mingling` argument parser (Built-in)
@@ -101,6 +105,7 @@ pub mod picker {
///
/// <https://docs.rs/mingling_macros/latest/mingling_macros/>
#[allow(unused_imports)]
+#[cfg(feature = "macros")]
pub mod macros {
/// `#[chain]` - Used to generate a struct implementing the `Chain` trait via a method
pub use mingling_macros::chain;
@@ -178,9 +183,11 @@ pub mod macros {
}
/// derive macro `EnumTag`
+#[cfg(feature = "macros")]
pub use mingling_macros::EnumTag;
/// derive macro Groupped
+#[cfg(feature = "macros")]
pub use mingling_macros::Groupped;
/// derive macro `StructuralData` — marks a type as supporting structured output
@@ -188,10 +195,12 @@ pub use mingling_macros::Groupped;
pub use mingling_macros::StructuralData;
/// Example projects for `Mingling`, for learning how to use `Mingling`
+#[cfg(feature = "core")]
pub mod _mingling_examples {
pub use crate::example_docs::*;
}
+#[cfg(feature = "core")]
mod features;
/// Module for checking which features are enabled at compile time.
@@ -199,19 +208,23 @@ mod features;
/// Each constant re-exported from this module corresponds to a Cargo feature flag.
/// They can be used for conditional compilation or runtime branching based on
/// feature availability.
+#[cfg(feature = "core")]
pub mod feature {
include!("./features.rs");
}
+#[cfg(feature = "core")]
mod setups;
/// Setups provided by Mingling, which can extend command-line programs.
+#[cfg(feature = "core")]
pub mod setup {
pub use crate::setups::*;
pub use mingling_core::setup::*;
}
/// Mutable global resources provided within Mingling
+#[cfg(feature = "core")]
pub mod res;
/// The prelude module provides convenient re-exports of commonly used macros and traits.
@@ -227,34 +240,45 @@ pub mod res;
/// ```
pub mod prelude {
/// Re-export of the `Groupped` derive macro for grouping types.
+ #[cfg(feature = "core")]
pub use crate::Groupped;
/// Re-export of the `RenderResult` struct for outputting rendering result
+ #[cfg(feature = "core")]
pub use crate::RenderResult;
/// Re-export of the `chain` macro for defining a chain of commands.
+ #[cfg(feature = "macros")]
pub use crate::macros::chain;
/// Re-export of the `dispatcher` macro for routing commands.
+ #[cfg(feature = "macros")]
pub use crate::macros::dispatcher;
/// Re-export of the `empty_result` macro for creating an empty result value for early return.
- #[cfg(feature = "extra_macros")]
+ #[cfg(all(feature = "extra_macros", feature = "macros"))]
pub use crate::macros::empty_result;
/// Re-export of the `gen_program` macro for generating the program entry point.
+ #[cfg(feature = "macros")]
pub use crate::macros::gen_program;
/// Re-export of the `pack` macro for creating wrapper types.
+ #[cfg(feature = "macros")]
pub use crate::macros::pack;
/// Re-export of the `pack_err` macro for creating error types.
- #[cfg(feature = "extra_macros")]
+ #[cfg(all(feature = "extra_macros", feature = "macros"))]
pub use crate::macros::pack_err;
/// Re-export of the `renderer` macro for defining renderer functions.
+ #[cfg(feature = "macros")]
pub use crate::macros::renderer;
/// Like `pack_err!` but also marks the type for structured output
- #[cfg(all(feature = "structural_renderer", feature = "extra_macros"))]
+ #[cfg(all(
+ feature = "macros",
+ feature = "structural_renderer",
+ feature = "extra_macros"
+ ))]
pub use mingling_macros::pack_err_structural;
/// Like `pack!` but also marks the type for structured output
- #[cfg(feature = "structural_renderer")]
+ #[cfg(all(feature = "macros", feature = "structural_renderer"))]
pub use mingling_macros::pack_structural;
/// Re-export of the `completion` macro for generating completion entries.
- #[cfg(feature = "comp")]
+ #[cfg(all(feature = "macros", feature = "comp"))]
pub use crate::macros::completion;
/// Re-export of the `AsPicker` trait for picker functionality.
@@ -265,5 +289,6 @@ pub mod prelude {
pub use mingling_picker::prelude::*;
/// Used to enable the `writeln!` macro for `RenderResult`
+ #[cfg(feature = "core")]
pub use std::io::Write;
}
diff --git a/mingling_picker/src/picker/patterns.rs b/mingling_picker/src/picker/patterns.rs
index 9c42a46..a33860b 100644
--- a/mingling_picker/src/picker/patterns.rs
+++ b/mingling_picker/src/picker/patterns.rs
@@ -3,6 +3,7 @@ use mingling_picker_macros::internal_repeat;
use crate::{Pickable, Picker, PickerArgs, PickerFlag, PickerResult};
internal_repeat!(1..=32 => {
+ #[doc(hidden)]
pub struct PickerPattern$<'a, (T$,+)>
where (T$: Pickable + Default,+)
{