mirror of
https://seed.radicle.dev/rad:z2UcCU1LgMshWvXj6hXSDDrwB8q8M.git
synced 2026-10-18 19:30:30 +08:00
cli: add timestamp to output
With the Run storing the timestamp, it can be added to the CLI output as well. When pretty printing the timestamp, `chrono` is used to have a date-time format.
This commit is contained in:
Generated
+10
@@ -276,6 +276,15 @@ dependencies = [
|
||||
"cpufeatures",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "chrono"
|
||||
version = "0.4.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cipher"
|
||||
version = "0.4.4"
|
||||
@@ -1364,6 +1373,7 @@ dependencies = [
|
||||
name = "radicle-job"
|
||||
version = "0.4.0"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"clap",
|
||||
"indexmap",
|
||||
"nonempty 0.11.0",
|
||||
|
||||
@@ -12,6 +12,7 @@ edition = "2021"
|
||||
rust-version = "1.84.0"
|
||||
|
||||
[dependencies]
|
||||
chrono = { version = "0.4", default-features = false }
|
||||
clap = { version = "4.5.41", features = ["derive", "wrap_help"] }
|
||||
indexmap = { version = "2.7.1", features = ["serde"] }
|
||||
nonempty = "0.11.0"
|
||||
|
||||
+11
-2
@@ -3,7 +3,8 @@
|
||||
//! These can be used in tools that wish to display data, such as the `rad-job`
|
||||
//! CLI tool.
|
||||
|
||||
use radicle::{git::Oid, node::NodeId};
|
||||
use chrono::Utc;
|
||||
use radicle::{cob, git::Oid, node::NodeId};
|
||||
use serde::Serialize;
|
||||
use url::Url;
|
||||
use uuid::Uuid;
|
||||
@@ -78,6 +79,7 @@ impl Job {
|
||||
run_id: *run_id,
|
||||
status: *run.status(),
|
||||
log: run.log().clone(),
|
||||
timestamp: *run.timestamp(),
|
||||
})
|
||||
.collect();
|
||||
runs.sort_by_cached_key(|run| run.run_id);
|
||||
@@ -109,7 +111,13 @@ impl Job {
|
||||
for run in self.runs.iter() {
|
||||
line(&mut s, format!(" node {}", run.node_id));
|
||||
for run2 in run.runs.iter() {
|
||||
line(&mut s, format!(" run {} {:?}", run2.run_id, run2.status));
|
||||
let date =
|
||||
chrono::DateTime::<Utc>::from_timestamp_secs(run2.timestamp.as_secs() as i64)
|
||||
.expect("run timestamp is out of range");
|
||||
line(
|
||||
&mut s,
|
||||
format!(" run {} {:?} [{}]", run2.run_id, run2.status, date),
|
||||
);
|
||||
line(&mut s, format!(" log {}", run2.log));
|
||||
}
|
||||
}
|
||||
@@ -129,4 +137,5 @@ struct Run {
|
||||
run_id: Uuid,
|
||||
status: Status,
|
||||
log: Url,
|
||||
timestamp: cob::Timestamp,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user