refactor: extract path table creation into build_path_table function
This commit is contained in:
@@ -14,6 +14,43 @@ use prettytable::color;
|
|||||||
use prettytable::row;
|
use prettytable::row;
|
||||||
use prettytable::{Attr, Cell, Row, Table};
|
use prettytable::{Attr, Cell, Row, Table};
|
||||||
|
|
||||||
|
fn build_path_table(data_path: PathBuf, db_path: PathBuf) -> Table {
|
||||||
|
let mut path_table = Table::new();
|
||||||
|
|
||||||
|
if std::io::stdout().is_terminal() {
|
||||||
|
path_table.set_format(*FORMAT_BOX_CHARS_NO_BORDER_LINE_SEPARATOR);
|
||||||
|
} else {
|
||||||
|
path_table.set_format(*FORMAT_NO_BORDER_LINE_SEPARATOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
path_table.set_titles(Row::new(vec![
|
||||||
|
Cell::new("Type").with_style(Attr::Bold),
|
||||||
|
Cell::new("Path").with_style(Attr::Bold),
|
||||||
|
]));
|
||||||
|
|
||||||
|
path_table.add_row(Row::new(vec![
|
||||||
|
Cell::new("Data"),
|
||||||
|
Cell::new(
|
||||||
|
&data_path
|
||||||
|
.into_os_string()
|
||||||
|
.into_string()
|
||||||
|
.expect("Unable to convert data path to string"),
|
||||||
|
),
|
||||||
|
]));
|
||||||
|
|
||||||
|
path_table.add_row(Row::new(vec![
|
||||||
|
Cell::new("Database"),
|
||||||
|
Cell::new(
|
||||||
|
&db_path
|
||||||
|
.into_os_string()
|
||||||
|
.into_string()
|
||||||
|
.expect("Unable to convert DB path to string"),
|
||||||
|
),
|
||||||
|
]));
|
||||||
|
|
||||||
|
path_table
|
||||||
|
}
|
||||||
|
|
||||||
fn build_compression_table(_args: crate::Args, default_type: CompressionType) -> Table {
|
fn build_compression_table(_args: crate::Args, default_type: CompressionType) -> Table {
|
||||||
let mut compression_table = Table::new();
|
let mut compression_table = Table::new();
|
||||||
if std::io::stdout().is_terminal() {
|
if std::io::stdout().is_terminal() {
|
||||||
@@ -108,6 +145,7 @@ pub fn mode_status(
|
|||||||
]));
|
]));
|
||||||
|
|
||||||
let compression_table = build_compression_table(args, default_type());
|
let compression_table = build_compression_table(args, default_type());
|
||||||
|
let path_table = build_path_table(data_path, db_path);
|
||||||
|
|
||||||
println!("PATHS:");
|
println!("PATHS:");
|
||||||
path_table.printstd();
|
path_table.printstd();
|
||||||
|
|||||||
Reference in New Issue
Block a user