Update ichwh to 3.0 (#1267)

The [newest update for ichwh][changes] introduced some breaking changes.
This PR bumps the version and refactors the `which` command to take
these into account.

[changes]: https://gitlab.com/avandesa/ichwh-rs/blob/master/CHANGELOG.md#030-2020-01-22
This commit is contained in:
Alex van de Sandt 2020-01-22 18:26:49 -05:00 committed by Jonathan Turner
parent 66bd331ba9
commit 07191754bf
3 changed files with 18 additions and 24 deletions

16
Cargo.lock generated
View file

@ -1032,7 +1032,6 @@ checksum = "b6f16056ecbb57525ff698bb955162d0cd03bee84e6241c27ff75c08d8ca5987"
dependencies = [
"futures-channel",
"futures-core",
"futures-executor",
"futures-io",
"futures-sink",
"futures-task",
@ -1071,17 +1070,6 @@ version = "0.3.0-alpha.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b35b6263fb1ef523c3056565fa67b1d16f0a8604ff12b11b08c25f28a734c60a"
[[package]]
name = "futures-executor"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e274736563f686a837a0568b478bdabfeaec2dca794b5649b04e2fe1627c231"
dependencies = [
"futures-core",
"futures-task",
"futures-util",
]
[[package]]
name = "futures-executor-preview"
version = "0.3.0-alpha.19"
@ -1605,9 +1593,9 @@ dependencies = [
[[package]]
name = "ichwh"
version = "0.2.1"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ee706a4af782acda5a05b7641867dd9c93d7f2884f214fbbad009e5752228d1"
checksum = "ec27ed05786e59eb2e012b8693ab59abda5d76c7578ef1cde2eb5ff631c342ce"
dependencies = [
"async-std",
"cfg-if",

View file

@ -105,7 +105,7 @@ subprocess = "0.1.18"
pretty-hex = "0.1.1"
hex = "0.4"
tempfile = "3.1.0"
ichwh = "0.2"
ichwh = "0.3"
textwrap = {version = "0.11.0", features = ["term_size"]}
shellexpand = "1.1.1"
pin-utils = "0.1.0-alpha.4"

View file

@ -90,7 +90,7 @@ fn which(
if all {
let stream = async_stream! {
if external {
if let Ok(path) = ichwh::which(&item).await {
if let Ok(Some(path)) = ichwh::which(&item).await {
yield ReturnSuccess::value(entry_path!(item, path.into(), application.tag.clone()));
}
}
@ -125,19 +125,25 @@ fn which(
} else {
let stream = async_stream! {
if external {
if let Ok(path) = ichwh::which(&item).await {
if let Ok(Some(path)) = ichwh::which(&item).await {
yield ReturnSuccess::value(entry_path!(item, path.into(), application.tag.clone()));
}
} else if commands.has(&item) {
yield ReturnSuccess::value(entry_builtin!(item, application.tag.clone()));
} else if let Ok(path) = ichwh::which(&item).await {
yield ReturnSuccess::value(entry_path!(item, path.into(), application.tag.clone()));
} else {
yield Err(ShellError::labeled_error(
"Binary not found for argument, and argument is not a builtin",
"not found",
&application.tag,
));
match ichwh::which(&item).await {
Ok(Some(path)) => yield ReturnSuccess::value(entry_path!(item, path.into(), application.tag.clone())),
Ok(None) => yield Err(ShellError::labeled_error(
"Binary not found for argument, and argument is not a builtin",
"not found",
&application.tag,
)),
Err(_) => yield Err(ShellError::labeled_error(
"Error trying to find binary for argument",
"error",
&application.tag,
)),
}
}
};