tau: Do not print unnecessary table data when piping task table output

This commit is contained in:
parazyd
2023-08-12 16:54:19 +02:00
parent e0f0b46135
commit 3326e1b060
3 changed files with 14 additions and 2 deletions

1
Cargo.lock generated
View File

@@ -5946,6 +5946,7 @@ dependencies = [
"clap 4.3.21",
"colored",
"darkfi",
"libc",
"libsqlite3-sys",
"log",
"prettytable-rs",

View File

@@ -9,6 +9,7 @@ homepage = "https://dark.fi"
repository = "https://github.com/darkrenaissance/darkfi"
[dependencies]
libc = "0.2.147"
darkfi = { path = "../../../", features = ["rpc"]}
# Async

View File

@@ -117,8 +117,18 @@ pub fn print_task_list(tasks: Vec<TaskInfo>, ws: String) -> Result<()> {
.build(),
);
ws_table.printstd();
table.printstd();
if unsafe { libc::isatty(libc::STDOUT_FILENO) } == 1 {
ws_table.printstd();
table.printstd();
} else {
for row in table.row_iter() {
for cell in row.iter() {
print!("{}\t", cell.get_content());
}
print!("\n");
}
}
Ok(())
}