Skip to content

Commit

Permalink
update: renamed take_args to take_opt_args
Browse files Browse the repository at this point in the history
  • Loading branch information
sttk committed Aug 5, 2024
1 parent b6247fa commit e4d7611
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn parse_args<'a, F1, F2, F3>(
args: &[&'a str],
mut collect_args: F1,
mut collect_opts: F2,
take_args: F3,
take_opt_args: F3,
) -> Result<(), InvalidOption>
where
F1: FnMut(&'a str),
Expand Down Expand Up @@ -84,7 +84,7 @@ where
}

if i == arg.len() {
if take_args(arg) && i_arg < args.len() - 1 {
if take_opt_args(arg) && i_arg < args.len() - 1 {
prev_opt_taking_args = arg;
continue 'L0;
}
Expand Down Expand Up @@ -148,7 +148,7 @@ where
}

if i == arg.len() && !name.is_empty() {
if take_args(name) && i_arg < args.len() - 1 {
if take_opt_args(name) && i_arg < args.len() - 1 {
prev_opt_taking_args = name;
} else {
match collect_opts(name, None) {
Expand Down
4 changes: 2 additions & 2 deletions src/parse/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ impl<'a> Cmd<'a> {
Ok(())
};

let take_args = |_arg: &str| false;
let take_opt_args = |_arg: &str| false;

if !self._leaked_strs.is_empty() {
match parse_args(
&self._leaked_strs[1..],
collect_args,
collect_opts,
take_args,
take_opt_args,
) {
Ok(_) => {}
Err(err) => return Err(err),
Expand Down
4 changes: 2 additions & 2 deletions src/parse/parse_with.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl<'a> Cmd<'a> {
return Ok(());
}

let take_args = |opt: &str| {
let take_opt_args = |opt: &str| {
if let Some(i) = cfg_map.get(opt) {
return opt_cfgs[*i].has_arg;
}
Expand Down Expand Up @@ -237,7 +237,7 @@ impl<'a> Cmd<'a> {
&self._leaked_strs[1..],
collect_args,
collect_opts,
take_args,
take_opt_args,
);

for str_ref in str_refs {
Expand Down

0 comments on commit e4d7611

Please sign in to comment.