Add "Enqueued At" to `pueue status`
If at least one task is delayed, show a column titled "Enqueue At" with
a timestamp when it will be moved from stashed to queued.
@@ -45,13 +45,17 @@ pub fn print_state(message: Message, json: bool) {
}
println!("{}", daemon_status);
- let mut table = Table::new();
- table
- .set_content_arrangement(ContentArrangement::Dynamic)
- .load_preset(UTF8_HORIZONTAL_BORDERS_ONLY)
- .set_header(vec![
- Cell::new("Index"),
- Cell::new("Status"),
+ let has_delayed_tasks = state
+ .tasks
+ .iter()
+ .find(|(_id, task)| task.enqueue_at.is_some())
+ .is_some();
+
+ let mut headers = vec![Cell::new("Index"), Cell::new("Status")];
+ if has_delayed_tasks {
+ headers.push(Cell::new("Enqueue At"));
+ }
+ headers.append(&mut vec![
Cell::new("Exitcode"),
Cell::new("Command"),
Cell::new("Path"),
@@ -59,6 +63,12 @@ pub fn print_state(message: Message, json: bool) {
Cell::new("End"),
]);
+ let mut table = Table::new();
+ table
+ .set_content_arrangement(ContentArrangement::Dynamic)
+ .load_preset(UTF8_HORIZONTAL_BORDERS_ONLY)
+ .set_header(headers);
+
for (id, task) in state.tasks {
let mut row = Row::new();
// Add a row per time
@@ -74,6 +84,14 @@ pub fn print_state(message: Message, json: bool) {
};
row.add_cell(status_cell);
+ if has_delayed_tasks {
+ if let Some(enqueue_at) = task.enqueue_at {
+ row.add_cell(Cell::new(enqueue_at.format("%Y-%m-%d\n%H:%M:%S")));
+ } else {
+ row.add_cell(Cell::new(""));
+ }
+ }
+
// Match the color of the exit code
// If the exit_code is none, it has been killed by the task handler.
match task.exit_code {
