sausage core: modules per topic, journal writer thread with WAL and batches, hash cache by metadata, 49 tests per rule
Blank stdout lines give no warning. core.exit requests the exit in its own handler.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
//! The minimal console reads explicit JSON-RPC calls and the quit command.
|
||||
use crate::Host;
|
||||
use tokio::io::{AsyncBufReadExt, BufReader};
|
||||
|
||||
/// Read console lines until EOF or quit, and print each call's result.
|
||||
pub async fn run_input(host: Host) -> anyhow::Result<()> {
|
||||
let mut lines = BufReader::new(tokio::io::stdin()).lines();
|
||||
while let Some(line) = lines.next_line().await? {
|
||||
if line == "quit" {
|
||||
break;
|
||||
}
|
||||
let (method, params) = line.split_once(' ').unwrap_or((&line, "{}"));
|
||||
match serde_json::from_str(params) {
|
||||
Ok(params) => {
|
||||
let value = match host.call(method, params).await {
|
||||
Ok(value) | Err(value) => value,
|
||||
};
|
||||
println!("{value}");
|
||||
}
|
||||
Err(error) => eprintln!("{error}"),
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user