mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Don't consume command args that fail parsing, so that optional args are properly skipped.
This commit is contained in:
parent
6d101419c7
commit
008e9051f7
@ -443,9 +443,14 @@ fn edit_setting_feedback<S: EditableSetting>(
|
||||
macro_rules! parse_args {
|
||||
($args:expr, $($t:ty),* $(, ..$tail:ty)? $(,)?) => {
|
||||
{
|
||||
let mut args = $args.into_iter();
|
||||
let mut args = $args.into_iter().peekable();
|
||||
(
|
||||
$(args.next().and_then(|s| s.parse::<$t>().ok())),*
|
||||
$({
|
||||
let parsed = args.peek().and_then(|s| s.parse::<$t>().ok());
|
||||
// Consume successfully parsed arg.
|
||||
if parsed.is_some() { args.next(); }
|
||||
parsed
|
||||
}),*
|
||||
$(, args.map(|s| s.to_string()).collect::<$tail>())?
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user