pub fn parse_known<T: Parser, S>(
args: impl IntoIterator<Item = S>,
) -> (T, Option<impl Iterator<Item = S>>)Expand description
This function and the try_parse_known exists to deal with
the Clap’s limitation of treating -- like a regular value
https://github.com/clap-rs/clap/issues/5055
§Arguments
args- An Iterator fromstd::env::args
§Returns
- a parsed struct T from
clap::Parser::parse_from - the remain iterator
argswith--and the rest arguments if they present othervise None
§Examples
use clap::{builder::styling, Parser};
#[derive(Parser)]
struct CommandLineArgs {
#[clap(allow_hyphen_values = true, num_args=1..)]
script_args: Vec<String>,
}
let (mut parsed_args, raw_args) =
brush_core::builtins::parse_known::<CommandLineArgs, _>(std::env::args());
if raw_args.is_some() {
parsed_args.script_args = raw_args.unwrap().collect();
}