diff options
author | Matthias Beyer <matthias.beyer@atos.net> | 2019-04-25 09:54:00 +0200 |
---|---|---|
committer | Matthias Beyer <matthias.beyer@atos.net> | 2019-04-25 09:56:25 +0200 |
commit | 430705439de90327be98d2cc3ae658cdce9edf9f (patch) | |
tree | 0f0eb581ba6fc6feb77df3e03e4264bddec07453 | |
parent | 66c91849ebd5e4b1161704a79527f3145b03208f (diff) |
Refactor: Add helper for printing table
-rw-r--r-- | src/frontend/table.rs | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/src/frontend/table.rs b/src/frontend/table.rs index 2440161..35c867c 100644 --- a/src/frontend/table.rs +++ b/src/frontend/table.rs @@ -36,6 +36,12 @@ impl TableFrontend { table.set_titles(row!["Name", "Version", "Repo", "Status", "URL"]); table } + + fn print(&self, table: Table) -> Result<()> { + let mut outlock = self.0.lock(); + table.print(&mut outlock)?; + Ok(()) + } } impl Frontend for TableFrontend { @@ -60,11 +66,7 @@ impl Frontend for TableFrontend { table.add_row(row![package.name(), package.version(), package.repo(), status, url]); }); - - let mut outlock = self.0.lock(); - table.print(&mut outlock)?; - - Ok(()) + self.print(table) } fn list_problems(&self, problems: Vec<Problem>) -> Result<()> { @@ -79,11 +81,7 @@ impl Frontend for TableFrontend { problem.problem_description() ]); }); - - let mut outlock = self.0.lock(); - table.print(&mut outlock)?; - - Ok(()) + self.print(table) } fn compare_packages(&self, packages: Vec<ComparePackage>, backend: &Backend, filter_repos: Vec<Repo>) -> Result<()> { @@ -102,11 +100,7 @@ impl Frontend for TableFrontend { ]); }); } - - let mut outlock = self.0.lock(); - table.print(&mut outlock)?; - - Ok(()) + self.print(table) } } |