Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser logic clean up #2320

Merged
merged 14 commits into from
Feb 5, 2021
4 changes: 4 additions & 0 deletions src/build/app/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1046,12 +1046,16 @@ pub enum AppSettings {
TrailingValues,

#[doc(hidden)]
/// If the app is already built, used for caching.
Built,

#[doc(hidden)]
/// If the app's bin name is already built, used for caching.
BinNameBuilt,

#[doc(hidden)]
/// This is paired with `ArgsNegateSubcommands`. Used to determine if we
/// already met any valid arg(then we shouldn't expect subcommands after it).
ValidArgFound,

#[doc(hidden)]
Expand Down
4 changes: 3 additions & 1 deletion src/output/usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ impl<'help, 'app, 'parser> Usage<'help, 'app, 'parser> {
// `incl_last`: should we include args that are Arg::Last? (i.e. `prog [foo] -- [last]). We
// can't do that for required usages being built for subcommands because it would look like:
// `prog [foo] -- [last] <subcommand>` which is totally wrong.
// TODO: remove the allow clippy when we update the compiler version.
#[allow(clippy::needless_collect)]
pub(crate) fn get_required_usage_from(
&self,
incls: &[Id],
Expand Down Expand Up @@ -419,7 +421,7 @@ impl<'help, 'app, 'parser> Usage<'help, 'app, 'parser> {

for p in pmap.values() {
debug!("Usage::get_required_usage_from:iter:{:?}", p.id);
if args_in_groups.is_empty() || !args_in_groups.contains(&p.id) {
if !args_in_groups.contains(&p.id) {
ret_val.push(p.to_string());
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/parse/arg_matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ impl ArgMatcher {

pub(crate) fn add_val_to(&mut self, arg: &Id, val: OsString, ty: ValueType) {
let ma = self.entry(arg).or_insert(MatchedArg {
occurs: 0, // @TODO @question Shouldn't this be 1 if we're already adding a value to this arg?
// We will manually inc occurrences later(for flexibility under
// specific circumstances, like only add one occurrence for flag
// when we met: `--flag=one,two`).
occurs: 0,
ty,
indices: Vec::with_capacity(1),
vals: Vec::with_capacity(1),
Expand Down
Loading