From 0bded81c4e205e387998bf64087acfc39cf70e3e Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Thu, 16 Jul 2026 03:27:19 +0800 Subject: feat(picker): add from_args and from_args_skip constructors --- mingling_picker/src/picker.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/mingling_picker/src/picker.rs b/mingling_picker/src/picker.rs index acdb8b5..d065891 100644 --- a/mingling_picker/src/picker.rs +++ b/mingling_picker/src/picker.rs @@ -24,6 +24,31 @@ pub struct Picker<'a, Route = ()> { args: PickerArgs<'a>, } +impl<'a> Picker<'a> { + /// Creates a new `Picker` from the command-line arguments (excluding the program name). + /// + /// This is equivalent to calling `std::env::args().skip(1)`, which + /// collects all arguments passed to the program except the first one + /// (the executable path). + pub fn from_args() -> Picker<'a, ()> { + Self::from_args_skip(1) + } + + /// Creates a new `Picker` from the command-line arguments, skipping the + /// first `skip` entries. + /// + /// This method is useful when you want more control over which arguments + /// are included. For example, pass `skip = 2` to skip both the program + /// name and the first argument. + pub fn from_args_skip(skip: usize) -> Picker<'a, ()> { + let args = std::env::args().skip(skip).collect::>(); + Picker { + route_phantom: PhantomData, + args: PickerArgs::Owned(args), + } + } +} + /// Internal arguments of Picker /// /// - `Slice` - borrowed slice of string slices -- cgit