Fix validator lookup by title.
We want the lookup to yield a result when there's only a single validator; and no title is provided. So that users can simply do 'aiken address' in their project if it's unambiguous. The validator's name is only required to disambiguate between multiple validators. I also noticed that the order of arguments in with_validator was wrong. Somehow.
This commit is contained in:
@@ -61,8 +61,7 @@ where
|
||||
let mut validator = None;
|
||||
|
||||
for v in self.validators.iter() {
|
||||
let match_title = title.map(|t| v.title.contains(t)).unwrap_or(false);
|
||||
|
||||
let match_title = Some(&v.title) == title.or(Some(&v.title));
|
||||
if match_title {
|
||||
validator = Some(if validator.is_none() {
|
||||
LookupResult::One(v)
|
||||
@@ -78,8 +77,8 @@ where
|
||||
pub fn with_validator<F, A, E>(
|
||||
&self,
|
||||
title: Option<&String>,
|
||||
when_missing: fn(Vec<String>) -> E,
|
||||
when_too_many: fn(Vec<String>) -> E,
|
||||
when_missing: fn(Vec<String>) -> E,
|
||||
action: F,
|
||||
) -> Result<A, E>
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user