refactor: extract json_display
This commit is contained in:
1 parent
8d7ac62f80
commit
953feee4c4
2 files changed
+12
-11
No files matched your search
@@ -48,6 +48,12 @@ pub async fn login_action<R>(
|
||||
Ok(return_data)
|
||||
}
|
||||
|
||||
pub fn json_display(value: impl Serialize) -> Result<(), Box<dyn snafu::Error>> {
|
||||
let lock = stdout().lock();
|
||||
serde_json::to_writer_pretty(lock, &value)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn human_readable_display(
|
||||
value: impl Display + Serialize,
|
||||
human_readable: bool,
|
||||
@@ -55,8 +61,7 @@ pub fn human_readable_display(
|
||||
if human_readable {
|
||||
println!("{value}");
|
||||
} else {
|
||||
let lock = stdout().lock();
|
||||
serde_json::to_writer_pretty(lock, &value)?;
|
||||
json_display(value)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in new issue
Block a user