Browse Source

bin/tau: print the current workspace name with tasks table

Dastan-glitch 4 years ago
parent
commit
0a23b180a1
2 changed files with 16 additions and 0 deletions
  1. 1 0
      bin/tau/tau-cli/src/primitives.rs
  2. 15 0
      bin/tau/tau-cli/src/view.rs

+ 1 - 0
bin/tau/tau-cli/src/primitives.rs

@@ -50,6 +50,7 @@ pub struct BaseTask {
 #[derive(serde::Serialize, serde::Deserialize, Debug)]
 pub struct TaskInfo {
     pub ref_id: String,
+    pub workspace: String,
     pub id: u32,
     pub title: String,
     pub desc: String,

+ 15 - 0
bin/tau/tau-cli/src/view.rs

@@ -46,6 +46,12 @@ pub fn print_task_list(tasks: Vec<TaskInfo>, filters: Vec<String>) -> Result<()>
         min_rank = last.rank;
     }
 
+    let workspace = if tasks.first().is_some() {
+        format!("Workspace: {}", tasks.first().unwrap().workspace.clone())
+    } else {
+        format!("Workspace: ")
+    };
+
     for task in tasks {
         let state = task.events.last().unwrap_or(&TaskEvent::default()).action.clone();
 
@@ -76,6 +82,15 @@ pub fn print_task_list(tasks: Vec<TaskInfo>, filters: Vec<String>) -> Result<()>
         ]));
     }
 
+    let mut ws_table = table!([Fb => workspace]);
+    ws_table.set_format(
+        FormatBuilder::new()
+            .padding(1, 1)
+            .separators(&[LinePosition::Bottom], LineSeparator::new('-', ' ', ' ', ' '))
+            .build(),
+    );
+
+    ws_table.printstd();
     table.printstd();
     Ok(())
 }