1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-04-19 19:34:24 +02:00

fix(cli): using zero exit code for error responses

This commit is contained in:
Jake Stanger 2024-05-18 17:01:36 +01:00
parent a33e0a241a
commit 8dda49477b
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
2 changed files with 10 additions and 1 deletions

View file

@ -1,7 +1,9 @@
use crate::error::ExitCode;
use crate::ipc::commands::Command;
use crate::ipc::responses::Response;
use clap::Parser;
use clap::{Parser, ValueEnum};
use serde::{Deserialize, Serialize};
use std::process::exit;
#[derive(Parser, Debug, Serialize, Deserialize)]
#[command(version)]
@ -38,6 +40,8 @@ pub enum Format {
}
pub fn handle_response(response: Response, format: Format) {
let is_err = matches!(response, Response::Err { .. });
match format {
Format::Plain => match response {
Response::Ok => println!("ok"),
@ -49,4 +53,8 @@ pub fn handle_response(response: Response, format: Format) {
serde_json::to_string(&response).expect("to be valid json")
),
}
if is_err {
exit(ExitCode::IpcResponseError as i32)
}
}

View file

@ -2,6 +2,7 @@
pub enum ExitCode {
GtkDisplay = 1,
CreateBars = 2,
IpcResponseError = 3,
}
pub const ERR_MUTEX_LOCK: &str = "Failed to get lock on Mutex";