Skip to content

Commit

Permalink
refactor: Clarify explicit display order wins
Browse files Browse the repository at this point in the history
Now that we use options, we can rely on that, instead of sentinels, for
detecting a default and overriding only a default.

Noticed this as part of looking at clap-rs#1807.
  • Loading branch information
epage committed Dec 9, 2021
1 parent ae2b315 commit d38452c
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/build/app/mod.rs
Expand Up @@ -2879,19 +2879,13 @@ impl<'help> App<'help> {
.args
.args_mut()
.filter(|a| !a.is_positional())
.filter(|a| a.get_display_order() == 999)
.filter(|a| a.provider != ArgProvider::Generated)
.enumerate()
{
a.disp_ord = Some(i);
a.disp_ord.get_or_insert(i);
}
for (i, mut sc) in &mut self
.subcommands
.iter_mut()
.enumerate()
.filter(|&(_, ref sc)| sc.get_display_order() == 999)
{
sc.disp_ord = Some(i);
for (i, sc) in &mut self.subcommands.iter_mut().enumerate() {
sc.disp_ord.get_or_insert(i);
}
}
for sc in &mut self.subcommands {
Expand Down

0 comments on commit d38452c

Please sign in to comment.