|
17 | 17 | import { readdir } from "fs" |
18 | 18 | import { Profiles } from "madwizard" |
19 | 19 | import { basename, join } from "path" |
| 20 | +import prettyMilliseconds from "pretty-ms" |
20 | 21 | import { Arguments, Table } from "@kui-shell/core" |
21 | 22 | import { setTabReadonly } from "@kui-shell/plugin-madwizard" |
22 | 23 |
|
@@ -57,15 +58,27 @@ function statusColor(status: Status) { |
57 | 58 | case "ERROR": |
58 | 59 | return "red-background" |
59 | 60 | case "RUNNING": |
60 | | - return "cyan-background" |
| 61 | + return "blue-background" |
61 | 62 | case "PENDING": |
62 | 63 | return "yellow-background" |
63 | 64 | default: |
64 | 65 | return "gray-background" |
65 | 66 | } |
66 | 67 | } |
67 | 68 |
|
68 | | -export default async function getProfiles(args: Arguments) { |
| 69 | +function formatDate(date: number): string { |
| 70 | + if (!date) { |
| 71 | + return "Running..." |
| 72 | + } |
| 73 | + return new Date(date).toLocaleString() |
| 74 | +} |
| 75 | + |
| 76 | +function getRunTime(start: number, end: number): string { |
| 77 | + const endTime = end || Date.now() |
| 78 | + return prettyMilliseconds(endTime - start, { secondsDecimalDigits: 0 }) |
| 79 | +} |
| 80 | + |
| 81 | +export default async function getRuns(args: Arguments) { |
69 | 82 | setTabReadonly(args) |
70 | 83 | const profile = args.parsedOptions.p || args.parsedOptions.profile |
71 | 84 |
|
@@ -97,6 +110,9 @@ export default async function getProfiles(args: Arguments) { |
97 | 110 | onclick: () => onClick(_.runDir), |
98 | 111 | attributes: [ |
99 | 112 | { key: "STATUS", value: capitalize(_.info.status), tag: "badge", css: statusColor(_.info.status) }, |
| 113 | + { key: "STARTED AT", value: formatDate(_.info.start_time) }, |
| 114 | + { key: "FINISHED AT", value: formatDate(_.info.end_time) }, |
| 115 | + { key: "RUN TIME", value: getRunTime(_.info.start_time, _.info.end_time) }, |
100 | 116 | ], |
101 | 117 | })), |
102 | 118 | } |
|
0 commit comments