Fix style

This commit is contained in:
surya 2024-07-31 13:04:54 +05:30
parent b489604327
commit 71087ee90c

View File

@ -29,52 +29,52 @@ struct Cli {
} }
fn json_to_int_value(number: &JsonValue) -> i64 { fn json_to_int_value(number: &JsonValue) -> i64 {
return match number { match number {
JsonValue::Number(_) => { JsonValue::Number(_) => {
return match number.as_f64() { match number.as_f64() {
Some(x) => x as i64, Some(x) => x as i64,
None => -1, None => -1,
} }
} }
_ => -2, _ => -2,
}; }
} }
fn str_to_int_value(number: Option<String>) -> i64 { fn str_to_int_value(number: Option<String>) -> i64 {
return match number { match number {
Some(x) => { Some(x) => {
return match x.trim().parse::<i64>() { match x.trim().parse::<i64>() {
Ok(y) => y, Ok(y) => y,
Err(y) => panic!("{}", y), Err(y) => panic!("{}", y),
}; }
} }
None => -1, None => -1,
}; }
} }
fn get_string_command_result(command: &mut Command) -> Option<String> { fn get_string_command_result(command: &mut Command) -> Option<String> {
let command_result = command.output(); let command_result = command.output();
return match command_result { match command_result {
Ok(x) => { Ok(x) => {
let status = String::from_utf8(x.stdout); let status = String::from_utf8(x.stdout);
return match status { match status {
Ok(x) => Some(x), Ok(x) => Some(x),
Err(_) => None, Err(_) => None,
}; }
} }
Err(_) => None, Err(_) => None,
}; }
} }
fn get_json_command_result(command: &mut Command) -> JsonValue { fn get_json_command_result(command: &mut Command) -> JsonValue {
let string_command_result = get_string_command_result(command); let string_command_result = get_string_command_result(command);
return match string_command_result { match string_command_result {
Some(x) => { Some(x) => {
return match json::parse(x.as_str()) { match json::parse(x.as_str()) {
Ok(x) => x, Ok(x) => x,
Err(_) => JsonValue::new_object(), Err(_) => JsonValue::new_object(),
}; }
} }
None => JsonValue::new_object(), None => JsonValue::new_object(),
}; }
} }