diff options
Diffstat (limited to 'mingling/src')
| -rw-r--r-- | mingling/src/example_docs.rs | 28 | ||||
| -rw-r--r-- | mingling/src/features.rs | 11 | ||||
| -rw-r--r-- | mingling/src/lib.rs | 36 | ||||
| -rw-r--r-- | mingling/src/picker_comp.rs | 52 |
4 files changed, 41 insertions, 86 deletions
diff --git a/mingling/src/example_docs.rs b/mingling/src/example_docs.rs index 3e9bd26..6f37a13 100644 --- a/mingling/src/example_docs.rs +++ b/mingling/src/example_docs.rs @@ -31,7 +31,7 @@ /// path = "../../mingling" /// /// # Enable `parser` features -/// features = ["parser", "extra_macros"] +/// features = ["parser", "extras"] /// /// [workspace] /// ``` @@ -161,7 +161,7 @@ pub mod example_argument_parse {} /// path = "../../mingling" /// /// # Enable `picker` features -/// features = ["picker", "extra_macros"] +/// features = ["picker", "extras"] /// /// [workspace] /// ``` @@ -713,7 +713,7 @@ pub mod example_clap_binding {} /// > AND `[build-dependencies]` so that pathf's builder can detect /// > `__internal_dispatcher_*` types needed by the dispatch tree. /// > -/// > Also requires `extra_macros` for the implicit `dispatcher!("hello")` form. +/// > Also requires `extras` for the implicit `dispatcher!("hello")` form. /// /// Run: /// ```bash @@ -735,7 +735,7 @@ pub mod example_clap_binding {} /// [dependencies] /// mingling = { path = "../../mingling", features = [ /// "dispatch_tree", -/// "extra_macros", +/// "extras", /// "pathf", /// ] } /// @@ -796,8 +796,8 @@ pub mod example_combine_pathf_dispatch_tree {} /// [dependencies.mingling] /// path = "../../mingling" /// features = [ -/// # Use `extra_macros` to introduce the `#[command]` macro -/// "extra_macros", +/// # Use `extras` to introduce the `#[command]` macro +/// "extras", /// /// # Use `picker` to parse arguments /// "picker", @@ -1052,7 +1052,7 @@ pub mod example_completion {} /// [dependencies.mingling] /// path = "../../mingling" /// -/// features = ["parser", "extra_macros"] +/// features = ["parser", "extras"] /// /// [workspace] /// ``` @@ -1780,7 +1780,7 @@ pub mod example_help {} pub mod example_hook {} /// Example Implicit Dispatcher /// -/// > This example demonstrates how to use the implicit `dispatcher!` definition syntax enabled by `extra_macros` +/// > This example demonstrates how to use the implicit `dispatcher!` definition syntax enabled by `extras` /// /// Source code (./Cargo.toml) /// ```toml @@ -1791,7 +1791,7 @@ pub mod example_hook {} /// /// [dependencies.mingling] /// path = "../../mingling" -/// features = ["extra_macros"] +/// features = ["extras"] /// /// [workspace] /// ``` @@ -1965,7 +1965,7 @@ pub mod example_lazy_resources {} /// [dependencies.mingling] /// path = "../../mingling" /// features = [ -/// "extra_macros", +/// "extras", /// ] /// /// [workspace] @@ -2096,7 +2096,7 @@ pub mod example_outside_type {} /// path = "../../mingling" /// features = [ /// "structural_renderer", -/// "extra_macros", +/// "extras", /// ] /// /// [workspace] @@ -2399,7 +2399,7 @@ pub mod example_pathfinder {} /// /// [dependencies.mingling] /// path = "../../mingling" -/// features = ["repl", "parser", "extra_macros"] +/// features = ["repl", "parser", "extras"] /// /// [dependencies] /// just_fmt = "0.1.2" @@ -2691,7 +2691,7 @@ pub mod example_resources {} /// edition = "2024" /// /// [dependencies] -/// mingling = { path = "../../mingling", features = ["extra_macros"] } +/// mingling = { path = "../../mingling", features = ["extras"] } /// /// [workspace] /// ``` @@ -2843,7 +2843,7 @@ pub mod example_structural_renderer {} /// edition = "2024" /// /// [dependencies] -/// mingling = { path = "../../mingling", features = ["extra_macros"] } +/// mingling = { path = "../../mingling", features = ["extras"] } /// /// [workspace] /// ``` diff --git a/mingling/src/features.rs b/mingling/src/features.rs index 0dde333..d1fcbd2 100644 --- a/mingling/src/features.rs +++ b/mingling/src/features.rs @@ -130,6 +130,17 @@ pub const MINGLING_EXTRA_MACROS: bool = false; #[cfg(feature = "extra_macros")] #[allow(unused)] pub const MINGLING_EXTRA_MACROS: bool = true; +/// Whether the `extras` feature is enabled +/// Current: `disabled` +#[cfg(not(feature = "extras"))] +#[allow(unused)] +pub const MINGLING_EXTRAS: bool = false; + +/// Whether the `extras` feature is enabled +/// Current: `enabled` +#[cfg(feature = "extras")] +#[allow(unused)] +pub const MINGLING_EXTRAS: bool = true; /// Whether the `json_serde_fmt` feature is enabled /// Current: `disabled` #[cfg(not(feature = "json_serde_fmt"))] diff --git a/mingling/src/lib.rs b/mingling/src/lib.rs index 3852191..c9c6d22 100644 --- a/mingling/src/lib.rs +++ b/mingling/src/lib.rs @@ -24,10 +24,6 @@ pub mod parser; #[cfg(feature = "picker")] pub mod picker; -/// Functionality when combining `picker` and `comp` -#[cfg(all(feature = "picker", feature = "comp"))] -pub mod picker_comp; - mod constants; /// Constants used throughout the Mingling framework. @@ -53,29 +49,29 @@ pub mod macros { pub use arg_picker::macros::*; pub use mingling_macros::buffer; pub use mingling_macros::chain; - #[cfg(feature = "extra_macros")] + #[cfg(feature = "extras")] pub use mingling_macros::command; #[cfg(feature = "comp")] pub use mingling_macros::completion; pub use mingling_macros::dispatcher; #[cfg(feature = "clap")] pub use mingling_macros::dispatcher_clap; - #[cfg(feature = "extra_macros")] + #[cfg(feature = "extras")] pub use mingling_macros::empty_result; - #[cfg(feature = "extra_macros")] + #[cfg(feature = "extras")] pub use mingling_macros::entry; pub use mingling_macros::gen_program; - #[cfg(feature = "extra_macros")] + #[cfg(feature = "extras")] pub use mingling_macros::group; - #[cfg(all(feature = "structural_renderer", feature = "extra_macros"))] + #[cfg(all(feature = "structural_renderer", feature = "extras"))] pub use mingling_macros::group_structural; pub use mingling_macros::help; pub use mingling_macros::mlint; pub use mingling_macros::node; pub use mingling_macros::pack; - #[cfg(feature = "extra_macros")] + #[cfg(feature = "extras")] pub use mingling_macros::pack_err; - #[cfg(all(feature = "structural_renderer", feature = "extra_macros"))] + #[cfg(all(feature = "structural_renderer", feature = "extras"))] pub use mingling_macros::pack_err_structural; #[cfg(feature = "structural_renderer")] pub use mingling_macros::pack_structural; @@ -86,7 +82,7 @@ pub mod macros { pub use mingling_macros::program_fallback_gen; #[doc(hidden)] pub use mingling_macros::program_final_gen; - #[cfg(feature = "extra_macros")] + #[cfg(feature = "extras")] pub use mingling_macros::program_setup; pub use mingling_macros::r_append; pub use mingling_macros::r_eprint; @@ -103,14 +99,14 @@ pub mod macros { pub use mingling_macros::register_renderer; #[doc(hidden)] pub use mingling_macros::register_type; - #[cfg(feature = "extra_macros")] + #[cfg(feature = "extras")] pub use mingling_macros::render_route; pub use mingling_macros::renderer; - #[cfg(feature = "extra_macros")] + #[cfg(feature = "extras")] pub use mingling_macros::renderify; - #[cfg(feature = "extra_macros")] + #[cfg(feature = "extras")] pub use mingling_macros::route; - #[cfg(feature = "extra_macros")] + #[cfg(feature = "extras")] pub use mingling_macros::routeify; #[cfg(feature = "comp")] pub use mingling_macros::suggest; @@ -181,24 +177,24 @@ pub mod prelude { pub use crate::Routable; #[cfg(feature = "macros")] pub use crate::macros::chain; - #[cfg(all(feature = "extra_macros", feature = "macros"))] + #[cfg(all(feature = "extras", feature = "macros"))] pub use crate::macros::command; #[cfg(feature = "macros")] pub use crate::macros::dispatcher; - #[cfg(all(feature = "extra_macros", feature = "macros"))] + #[cfg(all(feature = "extras", feature = "macros"))] pub use crate::macros::empty_result; #[cfg(feature = "macros")] pub use crate::macros::gen_program; #[cfg(feature = "macros")] pub use crate::macros::pack; - #[cfg(all(feature = "extra_macros", feature = "macros"))] + #[cfg(all(feature = "extras", feature = "macros"))] pub use crate::macros::pack_err; #[cfg(feature = "macros")] pub use crate::macros::renderer; #[cfg(all( feature = "macros", feature = "structural_renderer", - feature = "extra_macros" + feature = "extras" ))] pub use mingling_macros::pack_err_structural; #[cfg(all(feature = "macros", feature = "structural_renderer"))] diff --git a/mingling/src/picker_comp.rs b/mingling/src/picker_comp.rs deleted file mode 100644 index 26b0b5a..0000000 --- a/mingling/src/picker_comp.rs +++ /dev/null @@ -1,52 +0,0 @@ -use arg_picker::{Pickable, PickerArg, PickerArgInfo, parselib::ParserStyle}; -use mingling_core::{Suggest, SuggestItem}; - -/// Trait for converting picker arguments into `Suggest` items for autocompletion. -/// -/// This trait is implemented for `PickerArg` references and provides methods to -/// generate completion suggestions with optional descriptions. -pub trait PickerArgSuggest { - #[doc(hidden)] - fn into_suggest_raw(self, description: Option<&String>) -> Suggest; - - /// Converts the picker argument into a `Suggest` with the given description. - /// - /// The description is used when the suggestion item supports additional text, - /// such as `SuggestItem::WithDescription`. - fn into_suggest_with_desc(self, description: impl Into<String>) -> Suggest - where - Self: Sized, - { - let desc = description.into(); - self.into_suggest_raw(Some(&desc)) - } - - /// Converts the picker argument into a `Suggest` without a description. - /// - /// The resulting suggestion will use `SuggestItem::Simple` for each possible flag. - fn into_suggest(self) -> Suggest - where - Self: Sized, - { - self.into_suggest_raw(None) - } -} - -impl<'a, T> PickerArgSuggest for &'a PickerArg<'a, T> -where - T: Pickable<'a>, -{ - fn into_suggest_raw(self, description: Option<&String>) -> Suggest { - let mut suggest = Suggest::new(); - let info = PickerArgInfo::from(self); - let possible_flags = - arg_picker::parselib::build_possible_flags(ParserStyle::global_style(), &info); - for flag in possible_flags { - match description { - Some(desc) => suggest.insert(SuggestItem::WithDescription(flag, desc.clone())), - None => suggest.insert(SuggestItem::Simple(flag)), - }; - } - suggest - } -} |
