feat: replace output spawn with native tokio method
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -13,7 +13,7 @@ version.workspace = true
|
||||
anyhow.workspace = true
|
||||
tokio.workspace = true
|
||||
tracing.workspace = true
|
||||
tracing-subscriber.workspace = true
|
||||
tracing-subscriber = { workspace = true, features = ["env-filter"] }
|
||||
clap.workspace = true
|
||||
dotenv.workspace = true
|
||||
|
||||
|
@@ -52,7 +52,7 @@ impl LocalCopier {
|
||||
pub async fn paste(&self) -> anyhow::Result<Vec<u8>> {
|
||||
// FIXME: hardcode for macos
|
||||
#[cfg(target_os = "macos")]
|
||||
let mut paste_process = {
|
||||
let paste_process = {
|
||||
tokio::process::Command::new("pbpaste")
|
||||
.stdin(Stdio::piped())
|
||||
.spawn()?
|
||||
@@ -67,20 +67,19 @@ impl LocalCopier {
|
||||
let mut paste_process = {
|
||||
todo!("windows not supported yet");
|
||||
};
|
||||
let mut buf = Vec::new();
|
||||
|
||||
if let Some(mut stdout_handle) = paste_process.stdout.take() {
|
||||
stdout_handle
|
||||
.read_to_end(&mut buf)
|
||||
.await
|
||||
.context("failed to write input to paste process")?;
|
||||
let output = paste_process.wait_with_output().await?;
|
||||
|
||||
if !output.status.success() {
|
||||
anyhow::bail!(
|
||||
"output failed with: {}, {}, exit_code: {}",
|
||||
std::str::from_utf8(&output.stdout).unwrap_or_default(),
|
||||
std::str::from_utf8(&output.stderr).unwrap_or_default(),
|
||||
output.status.code().unwrap_or_default(),
|
||||
)
|
||||
}
|
||||
|
||||
let status = paste_process.wait().await?;
|
||||
|
||||
tracing::info!("paste process ended with status: {:?}", status);
|
||||
|
||||
Ok(buf)
|
||||
Ok(output.stdout)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -9,6 +9,7 @@ use remote_copy::RemoteCopierState;
|
||||
use state::State;
|
||||
use tokio::io::AsyncWriteExt;
|
||||
use tonic::transport;
|
||||
use tracing_subscriber::EnvFilter;
|
||||
|
||||
mod grpc {
|
||||
include!("gen/voidpin.v1.rs");
|
||||
@@ -64,7 +65,14 @@ enum RemoteCommands {
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
dotenv::dotenv().ok();
|
||||
tracing_subscriber::fmt::init();
|
||||
tracing_subscriber::fmt()
|
||||
.with_env_filter(
|
||||
EnvFilter::builder()
|
||||
.with_default_directive("error".parse().unwrap())
|
||||
.from_env_lossy(),
|
||||
)
|
||||
.with_writer(std::io::stderr)
|
||||
.init();
|
||||
|
||||
let cli = Command::parse();
|
||||
tracing::debug!("Starting cli");
|
||||
|
Reference in New Issue
Block a user