mirror of
https://github.com/nukesor/pueue
synced 2024-10-15 12:12:52 +00:00
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.
This commit is contained in:
parent
3c7bc7c746
commit
00415cbf94
|
@ -45,19 +45,29 @@ pub fn print_state(message: Message, json: bool) {
|
|||
}
|
||||
println!("{}", daemon_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"),
|
||||
Cell::new("Start"),
|
||||
Cell::new("End"),
|
||||
]);
|
||||
|
||||
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"),
|
||||
Cell::new("Exitcode"),
|
||||
Cell::new("Command"),
|
||||
Cell::new("Path"),
|
||||
Cell::new("Start"),
|
||||
Cell::new("End"),
|
||||
]);
|
||||
.set_header(headers);
|
||||
|
||||
for (id, task) in state.tasks {
|
||||
let mut row = Row::new();
|
||||
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue