Cli: Update OutputFormat method to return a String to restore consistency (#9904)

* Update OutputFormat method to return a String to restore consistency

* Remove process_show_account special case
This commit is contained in:
Tyera Eulberg
2020-05-06 20:27:15 -06:00
committed by GitHub
parent d5c889d6b0
commit 65a52a4145
7 changed files with 23 additions and 39 deletions

View File

@@ -26,20 +26,14 @@ pub enum OutputFormat {
}
impl OutputFormat {
pub fn formatted_print<T>(&self, item: &T)
pub fn formatted_string<T>(&self, item: &T) -> String
where
T: Serialize + fmt::Display,
{
match self {
OutputFormat::Display => {
println!("{}", item);
}
OutputFormat::Json => {
println!("{}", serde_json::to_string_pretty(item).unwrap());
}
OutputFormat::JsonCompact => {
println!("{}", serde_json::to_value(item).unwrap());
}
OutputFormat::Display => format!("{}", item),
OutputFormat::Json => serde_json::to_string_pretty(item).unwrap(),
OutputFormat::JsonCompact => serde_json::to_value(item).unwrap().to_string(),
}
}
}