summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock41
-rw-r--r--Cargo.toml1
-rw-r--r--src/config/input.rs15
3 files changed, 49 insertions, 8 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 940d658..6a217a5 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -57,6 +57,7 @@ dependencies = [
"clap",
"crossterm 0.28.1",
"dirs",
+ "duct",
"fancy-regex",
"futures-util",
"fuzzy-matcher",
@@ -847,6 +848,18 @@ dependencies = [
]
[[package]]
+name = "duct"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6ce170a0e8454fa0f9b0e5ca38a6ba17ed76a50916839d217eb5357e05cdfde"
+dependencies = [
+ "libc",
+ "os_pipe",
+ "shared_child",
+ "shared_thread",
+]
+
+[[package]]
name = "dyn-clone"
version = "1.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3019,6 +3032,23 @@ dependencies = [
]
[[package]]
+name = "shared_child"
+version = "1.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1e362d9935bc50f019969e2f9ecd66786612daae13e8f277be7bfb66e8bed3f7"
+dependencies = [
+ "libc",
+ "sigchld",
+ "windows-sys 0.60.2",
+]
+
+[[package]]
+name = "shared_thread"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c7a6f98357c6bb0ebace19b22220e5543801d9de90ffe77f8abb27c056bac064"
+
+[[package]]
name = "shell-words"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3031,6 +3061,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
+name = "sigchld"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1219ef50fc0fdb04fcc243e6aa27f855553434ffafe4fa26554efb78b5b4bf89"
+dependencies = [
+ "libc",
+ "os_pipe",
+ "signal-hook",
+]
+
+[[package]]
name = "signal-hook"
version = "0.3.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index 453381e..b6a8dea 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -67,6 +67,7 @@ bm25 = { version = "2.0.1", features = ["parallelism"] }
which = "8.0.0"
fuzzy-matcher = "0.3.7"
terminal-colorsaurus = "0.4.8"
+duct = "1.0.0"
[dependencies.reqwest]
version = "0.12.0"
diff --git a/src/config/input.rs b/src/config/input.rs
index 5c4e0e6..545e99d 100644
--- a/src/config/input.rs
+++ b/src/config/input.rs
@@ -94,7 +94,7 @@ impl Input {
}
let documents_len = documents.len();
for (kind, path, contents) in documents {
- if documents_len == 1 {
+ if documents_len == 1 && raw_text.is_empty() {
texts.push(format!("\n{contents}"));
} else {
texts.push(format!(
@@ -457,13 +457,12 @@ async fn load_documents(
let mut data_urls = HashMap::new();
for cmd in external_cmds {
- let (success, stdout, stderr) =
- run_command_with_output(&SHELL.cmd, &[&SHELL.arg, &cmd], None)?;
- if !success {
- let err = if !stderr.is_empty() { stderr } else { stdout };
- bail!("Failed to run `{cmd}`\n{err}");
- }
- files.push(("CMD", cmd, stdout));
+ let output = duct::cmd(&SHELL.cmd, &[&SHELL.arg, &cmd])
+ .stderr_to_stdout()
+ .unchecked()
+ .read()
+ .unwrap_or_else(|err| err.to_string());
+ files.push(("CMD", cmd, output));
}
let local_files = expand_glob_paths(&local_paths, true).await?;