mirror of
https://github.com/zyllian/webdog.git
synced 2025-01-18 03:32:21 -08:00
add utility for getting a current timestamp
This commit is contained in:
parent
f3a9662ca9
commit
5e9a23d789
1 changed files with 14 additions and 0 deletions
14
src/main.rs
14
src/main.rs
|
@ -7,11 +7,14 @@ use zyl_site::Site;
|
|||
enum Mode {
|
||||
Build,
|
||||
Serve,
|
||||
Now,
|
||||
}
|
||||
|
||||
#[cfg(feature = "serve")]
|
||||
#[tokio::main]
|
||||
async fn main() -> eyre::Result<()> {
|
||||
use time::{format_description::well_known::Rfc3339, OffsetDateTime};
|
||||
|
||||
#[cfg(feature = "color-eyre")]
|
||||
color_eyre::install()?;
|
||||
|
||||
|
@ -22,6 +25,9 @@ async fn main() -> eyre::Result<()> {
|
|||
if arg == "serve" {
|
||||
mode = Mode::Serve;
|
||||
break;
|
||||
} else if arg == "now" {
|
||||
mode = Mode::Now;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,6 +37,14 @@ async fn main() -> eyre::Result<()> {
|
|||
site.build_once()?
|
||||
}
|
||||
Mode::Serve => site.serve().await?,
|
||||
Mode::Now => {
|
||||
let time = OffsetDateTime::now_utc();
|
||||
println!(
|
||||
"{}",
|
||||
time.format(&Rfc3339)
|
||||
.expect("failed to format the current time")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
println!("Build complete!");
|
||||
|
|
Loading…
Add table
Reference in a new issue