Skip to content

Commit

Permalink
feat(cli): add elapsed time
Browse files Browse the repository at this point in the history
  • Loading branch information
SARDONYX-sard committed Dec 18, 2023
1 parent 5ed18aa commit ad640b7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions dar2oar_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ use clap::{arg, Parser};
use dar2oar_core::{convert_dar_to_oar, get_mapping_table, Closure, ConvertOptions};
use std::fs::File;
use std::str::FromStr;
use tokio::time::Instant;
use tracing::Level;

/// dar2oar --src "DAR path" --dist "OAR path"
#[derive(Debug, Parser)]
#[command(version, about)]
pub struct Args {
/// DAR source dir path
#[clap(long, value_parser)]
#[arg(long)]
src: String,
/// OAR destination dir path(If not, it is inferred from src)
#[clap(long, value_parser)]
#[arg(long)]
dist: Option<String>,
/// mod name in config.json & directory name(If not, it is inferred from src)
#[arg(long)]
Expand Down Expand Up @@ -42,6 +43,7 @@ pub struct Args {

#[tokio::main]
async fn main() -> anyhow::Result<()> {
let start = Instant::now();
let args = Args::parse();
tracing_subscriber::fmt()
.with_ansi(false)
Expand All @@ -63,6 +65,12 @@ async fn main() -> anyhow::Result<()> {
match convert_dar_to_oar(config, Closure::default).await {
Ok(msg) => {
tracing::info!("{}", msg);
let elapsed = start.elapsed();
tracing::info!(
"Conversion time: {}.{}secs.",
elapsed.as_secs(),
elapsed.subsec_millis()
);
Ok(())
}
Err(err) => {
Expand Down

0 comments on commit ad640b7

Please sign in to comment.