Skip to content

Commit

Permalink
feat(ping): emojify ping
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Apr 4, 2023
1 parent 03f7a7d commit a662765
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/commands/ping.rs
Expand Up @@ -17,18 +17,21 @@ pub struct PingCmd {

#[arg(from_global)]
json: bool,

#[arg(from_global)]
emoji: bool,
}

#[async_trait]
impl OroCommand for PingCmd {
async fn execute(self) -> Result<()> {
let start = Instant::now();
let registry = self.registry;
tracing::info!("ping: {registry}");
tracing::info!("{}ping: {registry}", if self.emoji { "🗣️ " } else { "" });
let client = OroClient::new(registry.clone());
let payload = client.ping().await?;
let time = start.elapsed().as_micros() as f32 / 1000.0;
tracing::info!("pong: {time}ms");
tracing::info!("{}pong: {time}ms", if self.emoji { "👂 " } else { "" });
if self.json {
let details: Value = serde_json::from_str(&payload)
.into_diagnostic()
Expand All @@ -42,7 +45,7 @@ impl OroCommand for PingCmd {
.wrap_err("ping::serialize")?;
println!("{output}");
} else {
tracing::info!("payload: {payload}");
tracing::info!("{}payload: {payload}", if self.emoji { "📦 " } else { "" });
}
Ok(())
}
Expand Down

0 comments on commit a662765

Please sign in to comment.