feat: add arguments for max responses

This commit is contained in:
Ashley Wulber 2025-01-23 17:59:07 -05:00 committed by Michael Murphy
parent 9f8f17a783
commit 0e01b09ddd
6 changed files with 180 additions and 9 deletions

View file

@ -8,6 +8,8 @@ use tokio::io::{AsyncBufReadExt, AsyncWriteExt};
use tokio::process;
use tokio_stream::wrappers::LinesStream;
use crate::Args;
#[derive(Debug)]
pub struct IpcClient {
pub child: process::Child,
@ -15,8 +17,16 @@ pub struct IpcClient {
}
impl IpcClient {
pub fn new() -> io::Result<(Self, impl Stream<Item = Response>)> {
pub fn new_with_args(args: Args) -> io::Result<(Self, impl Stream<Item = Response>)> {
let mut child = process::Command::new("pop-launcher")
.args(&[
"--max-open",
args.max_open.to_string().as_str(),
"--max-files",
args.max_files.to_string().as_str(),
"--max-search",
args.max_search.to_string().as_str(),
])
.stdin(std::process::Stdio::piped())
.stdout(std::process::Stdio::piped())
.spawn()?;
@ -46,6 +56,10 @@ impl IpcClient {
Ok((client, responses))
}
pub fn new() -> io::Result<(Self, impl Stream<Item = Response>)> {
Self::new_with_args(Args::default())
}
pub async fn send(&mut self, request: Request) -> io::Result<()> {
let mut request_json = serde_json::to_string(&request)
.map_err(|err| io::Error::new(io::ErrorKind::InvalidInput, err))?;