aboutsummaryrefslogtreecommitdiff
path: root/mingling/src/setups/picker
diff options
context:
space:
mode:
Diffstat (limited to 'mingling/src/setups/picker')
-rw-r--r--mingling/src/setups/picker/basic.rs7
-rw-r--r--mingling/src/setups/picker/consts.rs15
-rw-r--r--mingling/src/setups/picker/structural_renderer.rs12
3 files changed, 26 insertions, 8 deletions
diff --git a/mingling/src/setups/picker/basic.rs b/mingling/src/setups/picker/basic.rs
index 0539a09..318edbd 100644
--- a/mingling/src/setups/picker/basic.rs
+++ b/mingling/src/setups/picker/basic.rs
@@ -1,7 +1,10 @@
-use arg_picker::{IntoPicker, PickerArg, PickerArgs, value::Flag};
+use arg_picker::{IntoPicker, PickerArg, value::Flag};
use mingling_core::{Program, ProgramCollect, setup::ProgramSetup};
-use crate::setups::picker::{CONFIRM_FLAG, HELP_FLAG, QUIET_FLAG};
+use crate::{
+ setup::picker::REMAINS,
+ setups::picker::{CONFIRM_FLAG, HELP_FLAG, QUIET_FLAG},
+};
/// Helper: picks a boolean flag from the program arguments, calls `f` with the
/// flag value, then replaces the program arguments with the remaining args.
diff --git a/mingling/src/setups/picker/consts.rs b/mingling/src/setups/picker/consts.rs
index e254b4f..5e93f3f 100644
--- a/mingling/src/setups/picker/consts.rs
+++ b/mingling/src/setups/picker/consts.rs
@@ -1,6 +1,19 @@
use std::marker::PhantomData;
-use arg_picker::{PickerArg, value::Flag};
+use arg_picker::{PickerArg, PickerArgs, value::Flag};
+
+/// Remaining positional arguments (anything not consumed as an option).
+/// - `full`: `[]` (empty — not triggered by any `--` prefix).
+/// - `short`: (none)
+/// - `positional`: `false` (this is a meta‑argument that collects everything left).
+/// This constant is used internally to access any leftover arguments after
+/// all defined flags/options have been processed.
+pub const REMAINS: PickerArg<PickerArgs> = PickerArg::<PickerArgs> {
+ full: &[],
+ short: None,
+ positional: false,
+ internal_type: PhantomData,
+};
/// Help flag: display usage information.
/// - `full`: `["help"]`
diff --git a/mingling/src/setups/picker/structural_renderer.rs b/mingling/src/setups/picker/structural_renderer.rs
index 69f05f1..8e5eac6 100644
--- a/mingling/src/setups/picker/structural_renderer.rs
+++ b/mingling/src/setups/picker/structural_renderer.rs
@@ -1,8 +1,11 @@
-use arg_picker::{IntoPicker, PickerArg, PickerArgs};
+use arg_picker::IntoPicker;
use mingling_core::{Program, ProgramCollect, setup::ProgramSetup};
-use crate::setups::picker::{
- JSON_FLAG, JSON_PRETTY_FLAG, RON_FLAG, RON_PRETTY_FLAG, TOML_FLAG, YAML_FLAG,
+use crate::{
+ setup::picker::REMAINS,
+ setups::picker::{
+ JSON_FLAG, JSON_PRETTY_FLAG, RON_FLAG, RON_PRETTY_FLAG, TOML_FLAG, YAML_FLAG,
+ },
};
/// Sets up the structural renderer for the program:
@@ -47,7 +50,6 @@ fn process_renderer_flags<C>(args: Vec<String>, program: &mut Program<C>) -> Vec
where
C: ProgramCollect<Enum = C>,
{
- let remains_arg = PickerArg::<PickerArgs>::new(&[], None, true);
let (json, json_pretty, yaml, toml, ron, ron_pretty, remains) = args
.pick(&JSON_FLAG)
.pick(&JSON_PRETTY_FLAG)
@@ -55,7 +57,7 @@ where
.pick(&TOML_FLAG)
.pick(&RON_FLAG)
.pick(&RON_PRETTY_FLAG)
- .pick(&remains_arg)
+ .pick(&REMAINS)
.unwrap();
#[cfg(feature = "json_serde_fmt")]