Fix style
This commit is contained in:
parent
b489604327
commit
71087ee90c
30
src/main.rs
30
src/main.rs
@ -29,52 +29,52 @@ struct Cli {
|
||||
}
|
||||
|
||||
fn json_to_int_value(number: &JsonValue) -> i64 {
|
||||
return match number {
|
||||
match number {
|
||||
JsonValue::Number(_) => {
|
||||
return match number.as_f64() {
|
||||
match number.as_f64() {
|
||||
Some(x) => x as i64,
|
||||
None => -1,
|
||||
}
|
||||
}
|
||||
_ => -2,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
fn str_to_int_value(number: Option<String>) -> i64 {
|
||||
return match number {
|
||||
match number {
|
||||
Some(x) => {
|
||||
return match x.trim().parse::<i64>() {
|
||||
match x.trim().parse::<i64>() {
|
||||
Ok(y) => y,
|
||||
Err(y) => panic!("{}", y),
|
||||
};
|
||||
}
|
||||
}
|
||||
None => -1,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
fn get_string_command_result(command: &mut Command) -> Option<String> {
|
||||
let command_result = command.output();
|
||||
return match command_result {
|
||||
match command_result {
|
||||
Ok(x) => {
|
||||
let status = String::from_utf8(x.stdout);
|
||||
return match status {
|
||||
match status {
|
||||
Ok(x) => Some(x),
|
||||
Err(_) => None,
|
||||
};
|
||||
}
|
||||
}
|
||||
Err(_) => None,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
fn get_json_command_result(command: &mut Command) -> JsonValue {
|
||||
let string_command_result = get_string_command_result(command);
|
||||
return match string_command_result {
|
||||
match string_command_result {
|
||||
Some(x) => {
|
||||
return match json::parse(x.as_str()) {
|
||||
match json::parse(x.as_str()) {
|
||||
Ok(x) => x,
|
||||
Err(_) => JsonValue::new_object(),
|
||||
};
|
||||
}
|
||||
}
|
||||
None => JsonValue::new_object(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user