aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md8
-rw-r--r--arg_picker/src/arg.rs18
-rw-r--r--mingling/src/lib.rs4
-rw-r--r--mingling/src/picker_comp.rs52
4 files changed, 17 insertions, 65 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4780d0f..514d186 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -150,14 +150,6 @@ None
7. **[`core`]** **[`comp`]** Added `Suggest::combine(self, other: impl Into<Suggest>) -> Self` method that merges two `Suggest` values. If both are `Suggest::Suggest`, their inner `BTreeSet`s are merged (all items from `other` are added into `self`). Otherwise, the first `Suggest::Suggest` (or `FileCompletion`) is returned unchanged, and the other value is discarded. This enables ergonomic aggregation of completion suggestions from multiple sources.
-8. **[`picker_comp`]** Added `mingling::picker_comp` module behind `cfg(all(feature = "picker", feature = "comp"))` with a `PickerArgSuggest` trait and its implementation for `&PickerArg<'a, T>`. The trait provides:
-
- - **`into_suggest(self)`** — Converts the picker argument's known flags into a `Suggest` collection of `SuggestItem::Simple` entries.
- - **`into_suggest_with_desc(self, description)`** — Same as `into_suggest` but wraps each flag in `SuggestItem::WithDescription`.
- - **`into_suggest_raw(self, description: Option<&String>)`** — The core method; builds the list of possible flags from `arg_picker::parselib::build_possible_flags` and inserts each into the `Suggest` set, optionally carrying a description.
-
- This bridges the `picker` and `comp` (completion) subsystems, allowing picker arguments to be reused as completion candidates.
-
#### **BREAKING CHANGES** (API CHANGES):
1. **[`macros`]** **[BREAKING]** Renamed the `extra_macros` feature to `extras`. All feature-gated macro re-exports in `mingling/src/lib.rs` (and throughout the codebase) have been updated from `#[cfg(feature = "extra_macros")]` to `#[cfg(feature = "extras")]`.
diff --git a/arg_picker/src/arg.rs b/arg_picker/src/arg.rs
index 4fa21b5..0b5176d 100644
--- a/arg_picker/src/arg.rs
+++ b/arg_picker/src/arg.rs
@@ -1,4 +1,4 @@
-use crate::{Pickable, PickerArgInfo};
+use crate::{Pickable, PickerArgInfo, SinglePickable, parselib::ParserStyle};
use std::marker::PhantomData;
/// Represents a constraint definition for a parameter selection.
@@ -164,6 +164,22 @@ where
}
}
+impl<'a, Type> From<PickerArg<'a, Type>> for Vec<String>
+where
+ Type: SinglePickable,
+{
+ fn from(value: PickerArg<'a, Type>) -> Self {
+ let mut result = Vec::new();
+ let info = PickerArgInfo::from(value);
+ let possible_flags =
+ crate::parselib::build_possible_flags(ParserStyle::global_style(), &info);
+ for flag in possible_flags {
+ result.push(flag);
+ }
+ result
+ }
+}
+
/// Describes the attribute (behavior) of a command-line parameter.
///
/// The ordering reflects parse priority (higher = parsed first):
diff --git a/mingling/src/lib.rs b/mingling/src/lib.rs
index 6c1378c..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.
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
- }
-}