feat: ipc server and cli

This commit is contained in:
Jake Stanger
2023-06-22 23:06:45 +01:00
parent 93baf8f568
commit f5bdc5a027
10 changed files with 427 additions and 6 deletions

19
src/cli/mod.rs Normal file
View File

@@ -0,0 +1,19 @@
use crate::ipc::commands::Command;
use crate::ipc::responses::Response;
use clap::Parser;
use serde::{Deserialize, Serialize};
#[derive(Parser, Debug, Serialize, Deserialize)]
#[command(version)]
pub struct Args {
#[command(subcommand)]
pub command: Option<Command>,
}
pub fn handle_response(response: Response) {
match response {
Response::Ok => println!("ok"),
Response::OkValue { value } => println!("ok\n{value}"),
Response::Err { message } => eprintln!("error\n{}", message.unwrap_or_default()),
}
}