External it and nu variable column path fetch support. (#1379)

This commit is contained in:
Andrés N. Robalino
2020-02-11 18:25:56 -05:00
committed by GitHub
parent 24094acee9
commit 2ab8d035e6
6 changed files with 292 additions and 55 deletions

View File

@ -14,6 +14,18 @@ impl ExternalArg {
pub fn is_it(&self) -> bool {
self.has("$it")
}
pub fn is_nu(&self) -> bool {
self.has("$nu")
}
pub fn looks_like_it(&self) -> bool {
self.arg.starts_with("$it") && (self.arg.starts_with("$it.") || self.is_it())
}
pub fn looks_like_nu(&self) -> bool {
self.arg.starts_with("$nu") && (self.arg.starts_with("$nu.") || self.is_nu())
}
}
impl std::ops::Deref for ExternalArg {
@ -54,7 +66,11 @@ pub struct ExternalCommand {
impl ExternalCommand {
pub fn has_it_argument(&self) -> bool {
self.args.iter().any(|arg| arg.has("$it"))
self.args.iter().any(|arg| arg.looks_like_it())
}
pub fn has_nu_argument(&self) -> bool {
self.args.iter().any(|arg| arg.looks_like_nu())
}
}